<?php namespace app\api\lists\approve; use app\api\lists\BaseApiDataLists; use app\common\lists\ListsSearchInterface; use app\common\model\Approve; use app\common\model\user\User; class ApproveLists extends BaseApiDataLists implements ListsSearchInterface { /** * @notes 设置搜索条件 * @return \string[][] * @author likeadmin * @date 2023/08/31 11:08 */ public function setSearch(): array { $param = $this->request->param(); if (isset($param['check_status']) && $param['check_status'] == 0) { return [ '=' =>['type'] ]; } else { return [ '=' =>['type', 'check_status'] ]; } } public function queryWhere() { $where = []; // if (isset($param['type']) && $param['type'] == 2) { $adminId = User::where(['id' => $this->userId])->with('company')->value('admin_id'); $where[] = ['check_admin_ids', '=', $adminId]; // 只有片区经理才能查看 // } return $where; } public function lists(): array { return Approve::where($this->searchWhere) ->where($this->queryWhere()) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->withAttr('extend',function ($value, $data) { return json_decode($data['extend'], true); }) ->select() ->toArray(); } public function count(): int { return Approve::where($this->searchWhere)->count(); } }