request->param(); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$projectIds]; } return ProjectAlarmSet::where($this->searchWhere)->where($where) ->field(['id', 'project_id', 'material_budget_expenditure_ratio', 'labour_budget_expenditure_ratio', 'cost_budget_expenditure_ratio', 'subcontract_budget_expenditure_ratio']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; return $item; }) ->toArray(); } /** * @notes 获取项目预警设置数量 * @return int * @author likeadmin * @date 2023/12/14 16:24 */ public function count(): int { $params = $this->request->param(); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$projectIds]; } return ProjectAlarmSet::where($this->searchWhere)->where($where)->count(); } }