Commit e411fcb5 by LiuJunYi

地区接口,增加字段LEVEL

parent 71591851
...@@ -375,14 +375,14 @@ class Project extends Base ...@@ -375,14 +375,14 @@ class Project extends Base
$data['catalog_id'] = collection(CatalogsModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray(); $data['catalog_id'] = collection(CatalogsModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray();
$data['city'] = collection(CitysModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray(); $data['city'] = collection(CitysModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray();
$data['tags'] = collection(TagsModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray(); $data['tags'] = collection(TagsModel::order('sort', 'desc')->select())->visible(['id', 'name'])->toArray();
$data['level_1'] = collection(RegionModel::where(['level' => 1, 'pid' => 0])->select())->visible(['id', 'title'])->toArray(); $data['region_level_1'] = collection(RegionModel::where(['level' => 1, 'pid' => 0])->select())->visible(['id', 'title','level'])->toArray();
if (!$data) return ['code' => 1, 'msg' => '没有更多']; if (!$data) return ['code' => 1, 'msg' => '没有更多'];
array_unshift($data['type'], ['id' => '0', 'name' => "全部项目"]); array_unshift($data['type'], ['id' => '0', 'name' => "全部项目"]);
array_unshift($data['catalog_id'], ['id' => '0', 'name' => "全部分类"]); array_unshift($data['catalog_id'], ['id' => '0', 'name' => "全部分类"]);
array_unshift($data['city'], ['id' => '2', 'name' => "国外"]); array_unshift($data['city'], ['id' => '2', 'name' => "国外"]);
array_unshift($data['city'], ['id' => '1', 'name' => "国内"]); array_unshift($data['city'], ['id' => '1', 'name' => "国内"]);
array_unshift($data['city'], ['id' => '0', 'name' => "全部地区"]); array_unshift($data['city'], ['id' => '0', 'name' => "全部地区"]);
array_unshift($data['level_1'], ['id' => '0', 'title' => "全部"]); array_unshift($data['region_level_1'], ['id' => '0', 'title' => "全部","level"=>0]);
return ['code' => 0, 'msg' => 'success', 'data' => $data]; return ['code' => 0, 'msg' => 'success', 'data' => $data];
} }
...@@ -493,14 +493,14 @@ class Project extends Base ...@@ -493,14 +493,14 @@ class Project extends Base
public function queryRegion() public function queryRegion()
{ {
if (input('id') == 0) { if (input('id') == 0) {
return ['code' => 1, 'msg' => 'success', 'data' => [['id' => 0, 'title' => '全部']]]; return ['code' => 1, 'msg' => 'success', 'data' => [['id' => 0, 'title' => '全部', 'level' => 0]]];
} }
$list = RegionModel::where('pid', input('id'))->select(); $list = RegionModel::where('pid', input('id'))->select();
if(!$list){ if (!$list) {
return ['code' => 1, 'msg' => 'success', 'data' => [['id' => 0, 'title' => '全部']]]; return ['code' => 1, 'msg' => 'success', 'data' => [['id' => 0, 'title' => '全部', 'level' => 0]]];
} }
$list = collection($list)->visible(['id', 'title'])->toArray(); $list = collection($list)->visible(['id', 'title', 'level'])->toArray();
array_unshift($list,['id' => 0, 'title' => '全部']); array_unshift($list, ['id' => 0, 'title' => '全部',"level"=>0]);
return ['code' => 1, 'msg' => 'success', 'data' => $list]; return ['code' => 1, 'msg' => 'success', 'data' => $list];
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment