43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\lists\lottery;
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\lottery\LotteryDraw;
|
|
use app\common\model\lottery\LotteryCategory;
|
|
|
|
class LotteryDrawLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['category_id', 'status'],
|
|
];
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = LotteryDraw::where($this->searchWhere)
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order('draw_date', 'desc')
|
|
->order('id', 'desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
$catIds = array_unique(array_column($lists, 'category_id'));
|
|
$cats = LotteryCategory::whereIn('id', $catIds)->column('name', 'id');
|
|
|
|
foreach ($lists as &$item) {
|
|
$item['category_name'] = $cats[$item['category_id']] ?? '-';
|
|
}
|
|
|
|
return $lists;
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return LotteryDraw::where($this->searchWhere)->count();
|
|
}
|
|
}
|