作者 Karson

优化后台回收站列表逻辑

@@ -72,20 +72,14 @@ trait Backend @@ -72,20 +72,14 @@ trait Backend
72 $this->request->filter(['strip_tags', 'trim']); 72 $this->request->filter(['strip_tags', 'trim']);
73 if ($this->request->isAjax()) { 73 if ($this->request->isAjax()) {
74 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 74 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
75 - $total = $this->model  
76 - ->onlyTrashed()  
77 - ->where($where)  
78 - ->order($sort, $order)  
79 - ->count();  
80 75
81 $list = $this->model 76 $list = $this->model
82 ->onlyTrashed() 77 ->onlyTrashed()
83 ->where($where) 78 ->where($where)
84 ->order($sort, $order) 79 ->order($sort, $order)
85 - ->limit($offset, $limit)  
86 - ->select(); 80 + ->paginate($limit);
87 81
88 - $result = array("total" => $total, "rows" => $list); 82 + $result = array("total" => $list->total(), "rows" => $list->items());
89 83
90 return json($result); 84 return json($result);
91 } 85 }