增加土地列表关键字搜索 #9
|
@ -16,10 +16,16 @@
|
|||
//土地列表
|
||||
public function list(): Json
|
||||
{
|
||||
$params = $this->request->post(['page_no','page_size']);
|
||||
$params = $this->request->get(['page_no','page_size','keyword']);
|
||||
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
|
||||
$pageSize = empty($params['page_size']) ? 6 : $params['page_size'];
|
||||
$data = Land::where('user_id',$this->userId)->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){
|
||||
$where = [
|
||||
['user_id','=',$this->userId]
|
||||
];
|
||||
if(!empty($params['keyword'])){
|
||||
$where[] = ['title','like','%'.$params['keyword'].'%'];
|
||||
}
|
||||
$data = Land::where($where)->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){
|
||||
$item['pic'] = json_decode($item['pic']);
|
||||
return $item;
|
||||
})->toArray();
|
||||
|
|
Loading…
Reference in New Issue