1], [['limit'], 'default', 'value' => 20], ]; } public function search() { if (!$this->validate()) { return $this->getModelError(); } $where = ['o.store_id' => $this->store_id]; if (!empty($this->times)) { $explode = explode(' - ', $this->times); $where = [ 'and', ['>=', 'o.created_at', strtotime($explode[0])], ['<=', 'o.created_at', strtotime($explode[1])], ]; } $query = Dev::find()->alias('o') ->select('o.id,o.name,o.dev_number,o.created_at,o.status,s.name as store_name') ->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id') ->where([ ])->andWhere($where) ->andFilterWhere([ 'OR', ['like', 'o.name', $this->keywords], ['like', 'o.dev_numbe', $this->keywords], ]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item) { $item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }