|
@@ -3,6 +3,8 @@ namespace App\Http\Controllers;
|
|
|
use App\Models\ConfigCityManagement;
|
|
|
use App\Transformers\CityTransformer;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use App\Http\ApiHelper;
|
|
|
+use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
@@ -82,6 +84,31 @@ class ConfigCityManagementController extends Controller
|
|
|
|
|
|
public function edit(Request $request)
|
|
|
{
|
|
|
+ $data = $request->all();
|
|
|
+ $data['id'] = $request->input('id');
|
|
|
+ $cityManagement = ConfigCityManagement::where('id',$data['id'])->first();
|
|
|
+ if (!$cityManagement) {
|
|
|
+
|
|
|
+ return $this->response->array(ApiHelper::error('该城市不存在!', 402));
|
|
|
+ }
|
|
|
+
|
|
|
+ $rules = [
|
|
|
+ 'province_id' => 'required',
|
|
|
+ 'city_id' => 'required',
|
|
|
+ 'city_name' => 'required',
|
|
|
+ ];
|
|
|
+ $validator = Validator::make($data, $rules);
|
|
|
+ if ($validator->fails()) {
|
|
|
+
|
|
|
+ return $this->response->array(ApiHelper::error('请求参数格式不正确!', 412));
|
|
|
+ }
|
|
|
+ $city_management_update = $cityManagement->update($data);
|
|
|
+ if (!$city_management_update){
|
|
|
+
|
|
|
+ return $this->response->array(ApiHelper::error('修改失败,请重试!', 412));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->response->array(ApiHelper::success());
|
|
|
|
|
|
}
|
|
|
|