['project_id'], '%like%' => ['material_purchase_request_code'], ]; } /** * @notes 获取材料采购申请列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/01/09 13:47 */ public function lists(): array { return MaterialPurchaseRequest::where($this->searchWhere) ->field('id,project_id,material_purchase_request_code,apply_date,arrival_date,remark') ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; return $data; }) ->toArray(); } /** * @notes 获取材料采购申请数量 * @return int * @author likeadmin * @date 2024/01/09 13:47 */ public function count(): int { return MaterialPurchaseRequest::where($this->searchWhere)->count(); } }