|
|
<?php
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
use app\admin\controller\Index;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use think\Db;
|
|
|
use think\exception\DbException;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
|
|
|
|
|
/**
|
|
|
* 车辆管理
|
...
|
...
|
@@ -26,7 +23,7 @@ class Car extends Backend |
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = new \app\admin\model\Car;
|
|
|
|
|
|
$this->view->assign("statusList", $this->model->getStatusList());
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -55,19 +52,19 @@ class Car extends Backend |
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
|
|
$list = $this->model
|
|
|
->with(['route','driver','seat'])
|
|
|
->with(['route','seat','driver'])
|
|
|
->where($where)
|
|
|
->order($sort, $order)
|
|
|
->paginate($limit);
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
$row->visible(['id','car_model','license_plate','colour','reservation_time','start_time','create_time']);
|
|
|
$row->visible(['id','car_model','license_plate','seat','colour','driving_license','driver_license','reservation_time','start_time','create_time','status','carmodel_id']);
|
|
|
$row->visible(['route']);
|
|
|
$row->getRelation('route')->visible(['name']);
|
|
|
$row->visible(['driver']);
|
|
|
$row->getRelation('driver')->visible(['name']);
|
|
|
$row->visible(['seat']);
|
|
|
$row->getRelation('seat')->visible(['name']);
|
|
|
$row->visible(['driver']);
|
|
|
$row->getRelation('driver')->visible(['name']);
|
|
|
}
|
|
|
|
|
|
$result = array("total" => $list->total(), "rows" => $list->items());
|
...
|
...
|
@@ -76,7 +73,6 @@ class Car extends Backend |
|
|
}
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
...
|
...
|
@@ -112,8 +108,7 @@ class Car extends Backend |
|
|
// }
|
|
|
$route=Db::name("route")->where("id",$params['route_id'])->find();
|
|
|
$driver=Db::name("driver")->where("id",$params['driver_id'])->find();
|
|
|
$result = $this->model->allowField(true)->insertGetId($params);
|
|
|
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
$index=new Index();
|
|
|
$data=[
|
|
|
"start_address"=>$route["start_address"],
|
...
|
...
|
@@ -169,8 +164,7 @@ class Car extends Backend |
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
|
$result = $row->allowField(true)->insertGetId($params);
|
|
|
$this->getAccessToken($result);
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
...
|
...
|
@@ -182,5 +176,4 @@ class Car extends Backend |
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|