作者 王智

daima

@@ -43,36 +43,31 @@ class Renwu extends Backend @@ -43,36 +43,31 @@ class Renwu extends Backend
43 $this->relationSearch = true; 43 $this->relationSearch = true;
44 //设置过滤方法 44 //设置过滤方法
45 $this->request->filter(['strip_tags', 'trim']); 45 $this->request->filter(['strip_tags', 'trim']);
46 - if ($this->request->isAjax()) { 46 + if ($this->request->isAjax())
  47 + {
47 //如果发送的来源是Selectpage,则转发到Selectpage 48 //如果发送的来源是Selectpage,则转发到Selectpage
48 - if ($this->request->request('keyField')) { 49 + if ($this->request->request('keyField'))
  50 + {
49 return $this->selectpage(); 51 return $this->selectpage();
50 } 52 }
51 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 53 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
52 $total = $this->model 54 $total = $this->model
53 - ->alias('a')  
54 - ->with(['user', 'vip']) 55 + ->with(['user','vip'])
55 ->where($where) 56 ->where($where)
56 ->order($sort, $order) 57 ->order($sort, $order)
57 - ->join('user u', 'u.id= a.xi_id')  
58 - ->join('user b', 'b.id= a.zhao_id')  
59 ->count(); 58 ->count();
60 59
61 $list = $this->model 60 $list = $this->model
62 - ->with(['user', 'vip']) 61 + ->with(['user','vip'])
63 ->where($where) 62 ->where($where)
64 ->order($sort, $order) 63 ->order($sort, $order)
65 ->limit($offset, $limit) 64 ->limit($offset, $limit)
66 - ->join('user u', 'u.id= a.xi_id')  
67 - ->join('user b', 'b.id= a.zhao_id')  
68 ->select(); 65 ->select();
69 66
70 foreach ($list as $row) { 67 foreach ($list as $row) {
71 68
72 - $row->getRelation('user')->visible(['nickname', 'mobile', 'address', 'address_con', 'car_num', 'color', 'car_type', 'vip']); 69 + $row->getRelation('user')->visible(['nickname','mobile','address','address_con','car_num','color','car_type','vip']);
73 $row->getRelation('vip')->visible(['title']); 70 $row->getRelation('vip')->visible(['title']);
74 - $row->getRelation('xi_id')->visible(['nickname']);  
75 - $row->getRelation('zhao_id')->visible(['nickname']);  
76 } 71 }
77 $list = collection($list)->toArray(); 72 $list = collection($list)->toArray();
78 $result = array("total" => $total, "rows" => $list); 73 $result = array("total" => $total, "rows" => $list);
@@ -103,15 +103,6 @@ class Renwu extends Model @@ -103,15 +103,6 @@ class Renwu extends Model
103 return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); 103 return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
104 } 104 }
105 105
106 - public function xi_id()  
107 - {  
108 - return $this->belongsTo('User', 'xi_id', 'id', [], 'LEFT')->setEagerlyType(0);  
109 - }  
110 -  
111 - public function zhao_id()  
112 - {  
113 - return $this->belongsTo('User', 'zhao_id', 'id', [], 'LEFT')->setEagerlyType(0);  
114 - }  
115 106
116 public function vip() 107 public function vip()
117 { 108 {