@ -8,7 +8,7 @@ use App\Models\CarInfoT;
use Illuminate\Http\Request;
/**
* @title CarInfoController
* @title 车辆管理
* @description CarInfoController
* @package App\Http\Controllers\Api
* @author zcstatham
@ -19,8 +19,28 @@ class CarInfoController extends BaseController
protected $rules = [
'store' => [
'rules' => [
'car_no' => 'required',
'frame_no' => 'required',
'model_id' => 'numeric',
'car_no' => 'required|string',
'frame_no' => 'required|string',
'engine_no' => 'string',
'factory_model' => 'string',
'car_used_type' => 'string',
'car_man' => 'string',
'purchase_price' => 'string',
'register_date' => 'string',
'seat_count' => 'string',
'insurance_times' => 'numeric',
'insurance_serial_times' => 'numeric',
'repair_times' => 'numeric',
'insurance_repair_times' => 'numeric',
'last_insurance_company' => 'string',
'last_insurance_type' => 'string',
'last_insurance_rate' => 'numeric',
'last_insurance_salesman' => 'string',
'last_insurance_date' => 'string',
'force_expire_date' => 'string',
'business_expire_date' => 'string',
'status' => 'numeric',
]
],
'show' => [
@ -32,8 +52,28 @@ class CarInfoController extends BaseController
'update' => [
'rules' => [
'id' => 'bail|min:1',
'car_no' => 'required',
'frame_no' => 'required',
'model_id' => 'numeric',
'car_no' => 'required|string',
'frame_no' => 'required|string',
'engine_no' => 'string',
'factory_model' => 'string',
'car_used_type' => 'string',
'car_man' => 'string',
'purchase_price' => 'string',
'register_date' => 'string',
'seat_count' => 'string',
'insurance_times' => 'numeric',
'insurance_serial_times' => 'numeric',
'repair_times' => 'numeric',
'insurance_repair_times' => 'numeric',
'last_insurance_company' => 'string',
'last_insurance_type' => 'string',
'last_insurance_rate' => 'numeric',
'last_insurance_salesman' => 'string',
'last_insurance_date' => 'string',
'force_expire_date' => 'string',
'business_expire_date' => 'string',
'status' => 'numeric',
],
'custom' => [
'exists,App\Models\CarInfoT,id',
@ -56,8 +96,8 @@ class CarInfoController extends BaseController
}
/**
* @title 基础 列表
* @description 基础 列表
* @title 车辆 列表
* @description 车辆 列表
* @return \Illuminate\Http\JsonResponse
* @author zcstatham
*/
@ -65,7 +105,51 @@ class CarInfoController extends BaseController
{
$query = $this->model->query();
if(isset($this->params['name']) & & $this->params['name'] != ''){
if(isset($this->params['model_id']) & & $this->params['model_id'] != ''){
$query->where('model_id', $this->params['model_id']);
}
if(isset($this->params['car_no']) & & $this->params['car_no'] != ''){
$query->where('car_no', $this->params['car_no']);
}
if(isset($this->params['frame_no']) & & $this->params['frame_no'] != ''){
$query->where('frame_no', $this->params['frame_no']);
}
if(isset($this->params['engine_no']) & & $this->params['engine_no'] != ''){
$query->where('engine_no', $this->params['engine_no']);
}
if(isset($this->params['factory_model']) & & $this->params['factory_model'] != ''){
$query->where('factory_model', $this->params['factory_model']);
}
if(isset($this->params['car_used_type']) & & $this->params['car_used_type'] != ''){
$query->where('car_used_type', $this->params['car_used_type']);
}
if(isset($this->params['car_man']) & & $this->params['car_man'] != ''){
$query->where('car_man', $this->params['car_man']);
}
if(isset($this->params['purchase_price']) & & $this->params['purchase_price'] != ''){
$query->where('purchase_price', $this->params['purchase_price']);
}
if(isset($this->params['register_date']) & & $this->params['register_date'] != ''){
$query->where('register_date', $this->params['register_date']);
}
if(isset($this->params['last_insurance_date']) & & $this->params['name'] != ''){
$query->where('name', $this->params['name']);
}
if(isset($this->params['business_expire_date']) & & $this->params['name'] != ''){
$query->where('name', $this->params['name']);
}
if(isset($this->params['force_expire_date']) & & $this->params['name'] != ''){
$query->where('name', $this->params['name']);
}
@ -75,44 +159,45 @@ class CarInfoController extends BaseController
}
/**
* @title 基础 保存
* @description 基础 保存
* @title 车辆 保存
* @description 车辆 保存
* @return \Illuminate\Http\JsonResponse
* @author zcstatham
*/
public function store()
{
$this->model->car_no = $this->params['car_no'];
$this->model->frame_no = $this->params['frame_no'];
$this->model->engine_no = $this->params['engine_no'];
$this->model->factory_model = $this->params['factory_model'];
$this->model->car_used_type = $this->params['car_used_type'];
$this->model->car_man = $this->params['car_man'];
$this->model->purchase_price = $this->params['purchase_price'];
$this->model->register_date = $this->params['register_date'];
$this->model->seat_count = $this->params['seat_count'];
$this->model->insurance_times = $this->params['insurance_times'];
$this->model->insurance_serial_times = $this->params['insurance_serial_times'];
$this->model->repair_times = $this->params['repair_times'];
$this->model->insurance_repair_times = $this->params['insurance_repair_times'];
$this->model->last_insurance_company = $this->params['last_insurance_company'];
$this->model->last_insurance_type = $this->params['last_insurance_type'];
$this->model->last_insurance_rate = $this->params['last_insurance_rate'];
$this->model->last_insurance_salesman = $this->params['last_insurance_salesman'];
$this->model->last_insurance_date = $this->params['last_insurance_date'];
$this->model->force_expire_date = $this->params['force_expire_date'];
$this->model->business_expire_date = $this->params['business_expire_date'];
$this->model->status = $this->params['status'];
$this->model->model_id = $this->params['model_id'] ?? 0;
$this->model->car_no = $this->params['car_no'] ?? '';
$this->model->frame_no = $this->params['frame_no'] ?? '';
$this->model->engine_no = $this->params['engine_no'] ?? '';
$this->model->factory_model = $this->params['factory_model'] ?? '';
$this->model->car_used_type = $this->params['car_used_type'] ?? '';
$this->model->car_man = $this->params['car_man'] ?? '';
$this->model->purchase_price = $this->params['purchase_price'] ?? '';
$this->model->register_date = $this->params['register_date'] ?? '';
$this->model->seat_count = $this->params['seat_count'] ?? '';
$this->model->insurance_times = $this->params['insurance_times'] ?? 0;
$this->model->insurance_serial_times = $this->params['insurance_serial_times'] ?? 0;
$this->model->repair_times = $this->params['repair_times'] ?? 0;
$this->model->insurance_repair_times = $this->params['insurance_repair_times'] ?? 0;
$this->model->last_insurance_company = $this->params['last_insurance_company'] ?? '';
$this->model->last_insurance_type = $this->params['last_insurance_type'] ?? '';
$this->model->last_insurance_rate = $this->params['last_insurance_rate'] ?? 0;
$this->model->last_insurance_salesman = $this->params['last_insurance_salesman'] ?? '';
$this->model->last_insurance_date = $this->params['last_insurance_date'] ?? '';
$this->model->force_expire_date = $this->params['force_expire_date'] ?? '';
$this->model->business_expire_date = $this->params['business_expire_date'] ?? '';
$this->model->status = $this->params['status'] ?? 0;
if($this->model->save()){
return $this->success(new CarInfo($this->model));
} else {
return $this->error(500, '基础 信息保存失败');
return $this->error(500, '车辆 信息保存失败');
}
}
/**
* @title 基础 详情
* @description 基础 详情
* @title 车辆 详情
* @description 车辆 详情
* @param $id
* @return mixed
* @author zcstatham
@ -123,8 +208,8 @@ class CarInfoController extends BaseController
}
/**
* @title 基础 更新
* @description 基础 更新
* @title 车辆 更新
* @description 车辆 更新
* @param $id
* @return \Illuminate\Http\JsonResponse
* @author zcstatham
@ -132,47 +217,50 @@ class CarInfoController extends BaseController
public function update($id)
{
$this->model = $this->model->where('id', $id)->first();
$this->model->car_no = $this->params['car_no'];
$this->model->frame_no = $this->params['frame_no'];
$this->model->engine_no = $this->params['engine_no'];
$this->model->factory_model = $this->params['factory_model'];
$this->model->car_used_type = $this->params['car_used_type'];
$this->model->car_man = $this->params['car_man'];
$this->model->purchase_price = $this->params['purchase_price'];
$this->model->register_date = $this->params['register_date'];
$this->model->seat_count = $this->params['seat_count'];
$this->model->insurance_times = $this->params['insurance_times'];
$this->model->insurance_serial_times = $this->params['insurance_serial_times'];
$this->model->repair_times = $this->params['repair_times'];
$this->model->insurance_repair_times = $this->params['insurance_repair_times'];
$this->model->last_insurance_company = $this->params['last_insurance_company'];
$this->model->last_insurance_type = $this->params['last_insurance_type'];
$this->model->last_insurance_rate = $this->params['last_insurance_rate'];
$this->model->last_insurance_salesman = $this->params['last_insurance_salesman'];
$this->model->last_insurance_date = $this->params['last_insurance_date'];
$this->model->force_expire_date = $this->params['force_expire_date'];
$this->model->business_expire_date = $this->params['business_expire_date'];
$this->model->status = $this->params['status'];
$this->model->model_id = $this->params['model_id'] ?? 0;
$this->model->car_no = $this->params['car_no'] ?? '';
$this->model->frame_no = $this->params['frame_no'] ?? '';
$this->model->engine_no = $this->params['engine_no'] ?? '';
$this->model->factory_model = $this->params['factory_model'] ?? '';
$this->model->car_used_type = $this->params['car_used_type'] ?? '';
$this->model->car_man = $this->params['car_man'] ?? '';
$this->model->purchase_price = $this->params['purchase_price'] ?? '';
$this->model->register_date = $this->params['register_date'] ?? '';
$this->model->seat_count = $this->params['seat_count'] ?? '';
$this->model->insurance_times = $this->params['insurance_times'] ?? 0;
$this->model->insurance_serial_times = $this->params['insurance_serial_times'] ?? 0;
$this->model->repair_times = $this->params['repair_times'] ?? 0;
$this->model->insurance_repair_times = $this->params['insurance_repair_times'] ?? 0;
$this->model->last_insurance_company = $this->params['last_insurance_company'] ?? '';
$this->model->last_insurance_type = $this->params['last_insurance_type'] ?? '';
$this->model->last_insurance_rate = $this->params['last_insurance_rate'] ?? 0;
$this->model->last_insurance_salesman = $this->params['last_insurance_salesman'] ?? '';
$this->model->last_insurance_date = $this->params['last_insurance_date'] ?? '';
$this->model->force_expire_date = $this->params['force_expire_date'] ?? '';
$this->model->business_expire_date = $this->params['business_expire_date'] ?? '';
$this->model->status = $this->params['status'] ?? 0;
if($this->model->save()){
return $this->success(new CarInfo($this->model));
} else {
return $this->error(500, '基础 信息保存失败');
return $this->error(500, '车辆 信息保存失败');
}
}
/**
* @title 基础 删除
* @description 基础 删除
* @title 车辆 删除
* @description 车辆 删除
* @param $id
* @return \Illuminate\Http\JsonResponse
* @author zcstatham
*/
public function destroy($id)
{
if($this->model->destroy($id)){
$this->model = $this->model->where('id', $id)->first();
$this->model->status = 0;
if($this->model->save()){
return $this->success();
} else {
return $this->error(500, '基础 信息保存失败');
return $this->error(500, '车辆 信息保存失败');
}
}
}