From 9250233746e5e6957f1fdd52a11ca4668fa4fc8e Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Thu, 7 Sep 2023 13:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=87=AA=E6=9C=89=E8=BD=A6?= =?UTF-8?q?=E8=BE=86=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/validate/vehicle/VehicleValidate.php | 6 ++++-- app/api/controller/VehicleController.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/adminapi/validate/vehicle/VehicleValidate.php b/app/adminapi/validate/vehicle/VehicleValidate.php index 6b0170b9..764a2806 100644 --- a/app/adminapi/validate/vehicle/VehicleValidate.php +++ b/app/adminapi/validate/vehicle/VehicleValidate.php @@ -32,6 +32,7 @@ class VehicleValidate extends BaseValidate protected $rule = [ 'id' => 'require', 'license' => 'require|unique:vehicle', + 'pic' => 'require', 'gps_imei' => 'require|number|unique:vehicle', 'type' => 'require|in:0,1', 'status' => 'require|in:0,1,2', @@ -45,6 +46,7 @@ class VehicleValidate extends BaseValidate protected $field = [ 'id' => 'id', 'license' => '车辆牌照', + 'pic' => '车辆图片', 'gps_imei' => 'gps定位器设备标志', 'type' => '车辆类型:0:平台自营 1:社会车辆', 'status' => '车辆状态:0:未出租 1:签约中 2:已出租', @@ -59,7 +61,7 @@ class VehicleValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['license','gps_imei']); + return $this->only(['license','pic','gps_imei']); } @@ -71,7 +73,7 @@ class VehicleValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','license','gps_imei','status','type'])->remove('license', 'unique')->remove('gps_imei', 'unique'); + return $this->only(['id','license','pic','gps_imei','status','type'])->remove('license', 'unique')->remove('gps_imei', 'unique'); } diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php index 1981b8de..ba37ef65 100644 --- a/app/api/controller/VehicleController.php +++ b/app/api/controller/VehicleController.php @@ -2,7 +2,6 @@ namespace app\api\controller; use app\api\logic\VehicleLogic; -use app\common\model\contract\Contract; use app\common\model\vehicle\Vehicle; use app\common\model\vehicle\VehicleRent; use think\facade\Db; @@ -56,8 +55,8 @@ class VehicleController extends BaseApiController //添加自有车辆 public function addSelfCar() { //获取参数 - $params = $this->request->post(['license','company_id','company_name','company_user','company_phone']); - if(empty($params['license']) || empty($params['company_id']) || empty($params['company_name']) || empty($params['company_user']) || empty($params['company_phone'])){ + $params = $this->request->post(['license','pic','company_id','company_name','company_user','company_phone']); + if(empty($params['license']) || empty($params['pic']) || empty($params['company_id']) || empty($params['company_name']) || empty($params['company_user']) || empty($params['company_phone'])){ return $this->fail('缺少必要参数'); } Db::startTrans(); @@ -70,6 +69,7 @@ class VehicleController extends BaseApiController //写入数据 $vehicle = Vehicle::create([ 'license' => $params['license'], + 'pic' => $params['pic'], 'gps_imei' => '', 'type' => 1, 'status' => 2,