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(); } }