Commit f66eb343 by 庄欣

city

parent 0275fe2c
......@@ -21,4 +21,25 @@ class City extends Controller
return Response::success($model->get()->toArray());
}
public function parent($id)
{
try {
$info = CityModel::findOrFail($id);
$pid = $info->previous;
$parent = CityModel::findOrFail($pid);
return Response::success($parent->toArray());
} catch (ModelNotFoundException $e){
return Response::error(HttpStatus::HttpNotFound,"城市未找到");
}
}
public function show($id)
{
try {
$info = CityModel::findOrFail($id);
return Response::success($info->toArray());
} catch (ModelNotFoundException $e){
return Response::error(HttpStatus::HttpNotFound,"城市未找到");
}
}
}
......@@ -101,8 +101,8 @@ Route::group(["prefix" => "photo", 'namespace' => Provider::getNamespace("photo"
//城市
Route::group(["prefix" => "city", 'namespace' => Provider::getNamespace("city")],function(){
Route::get("/" , "City@index");
Route::get("/{id}/parent","City@parent");
Route::get("/{id}" , "City@show");
});
//关键词
......
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