作者 王智

daima

... ... @@ -43,31 +43,36 @@ class Renwu extends Backend
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['user','vip'])
->alias('a')
->with(['user', 'vip'])
->where($where)
->order($sort, $order)
->join('user u', 'u.id= a.xi_id')
->join('user u', 'u.id= a.zhao_id')
->count();
$list = $this->model
->with(['user','vip'])
->with(['user', 'vip'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->join('user u', 'u.id= a.xi_id')
->join('user u', 'u.id= a.zhao_id')
->select();
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','mobile','address','address_con','car_num','color','car_type','vip']);
$row->getRelation('user')->visible(['nickname', 'mobile', 'address', 'address_con', 'car_num', 'color', 'car_type', 'vip']);
$row->getRelation('vip')->visible(['title']);
$row->getRelation('xi_id')->visible(['nickname']);
$row->getRelation('zhao_id')->visible(['nickname']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -103,6 +103,15 @@ class Renwu extends Model
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function xi_id()
{
return $this->belongsTo('User', 'xi_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function zhao_id()
{
return $this->belongsTo('User', 'zhao_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function vip()
{
... ...