suyuan-breed/app/api/controller/FarmController.php

23 lines
738 B
PHP

<?php
namespace app\api\controller;
use app\common\model\farm\Farm;
class FarmController extends BaseApiController
{
public function lists()
{
$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'];
$where = [
['user_id','=',$this->userId]
];
if(!empty($params['keyword'])){
$where[] = ['farm_name','like','%'.$params['keyword'].'%'];
}
$data = Farm::where($where)->page($pageNo,$pageSize)->order('create_time desc')->select()->toArray();
return $this->success('请求成功',$data);
}
}