update
This commit is contained in:
parent
8333a2cd0d
commit
a3704c69e3
|
@ -18,6 +18,8 @@ namespace app\api\lists;
|
||||||
use app\adminapi\lists\BaseAdminDataLists;
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
use app\common\model\animal_info\AnimalInfo;
|
use app\common\model\animal_info\AnimalInfo;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\farm\Farm;
|
||||||
|
use app\common\model\fence_house\FenceHouse;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +57,14 @@ class AnimalInfoLists extends BaseApiDataLists implements ListsSearchInterface
|
||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return AnimalInfo::where($this->searchWhere)
|
$fenceHouseId = $this->request->get('fence_house_id', '');
|
||||||
|
$where = [];
|
||||||
|
if (empty($fenceHouseId)) {
|
||||||
|
$farmIds = Farm::where('user_id', $this->userId)->column('id');
|
||||||
|
$fenceHouseIds = FenceHouse::whereIn('farm_id', $farmIds)->column('id');
|
||||||
|
$where[] = ['fence_house_id', 'in', $fenceHouseIds];
|
||||||
|
}
|
||||||
|
return AnimalInfo::where($this->searchWhere)->where($where)
|
||||||
->with(['fenceHouseAttr'])
|
->with(['fenceHouseAttr'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
|
|
Loading…
Reference in New Issue