multi-store/app/common/lists/DeliveryServiceLists.php
2024-06-06 16:45:14 +08:00

45 lines
1.4 KiB
PHP

<?php
namespace app\common\lists;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\system_store\DeliveryService;
class DeliveryServiceLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
];
}
public function lists(): array
{
return DeliveryService::field('id,nickname,type,avatar,phone,status')
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
})
->when(!empty($this->params['keyword']), function ($query) {
$query->where('nickname|phone', 'like', "%{$this->params['keyword']}%");
})
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
public function count(): int
{
return DeliveryService::when(!empty($this->request->adminInfo['store_id']), function ($query) {
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
})
->when(!empty($this->params['keyword']), function ($query) {
$query->where('nickname|phone', 'like', "%{$this->params['keyword']}%");
})
->count();
}
}