['name', 'type', 'happen_time', 'device_accident'], ]; } /** * @notes 获取安全事故列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/19 14:28 */ public function lists(): array { return SafetyAccident::where($this->searchWhere) ->field(['id', 'org_id', 'dept_id', 'project_id', 'name', 'type', 'happen_time', 'device_accident', 'contractor_user', 'our_company_user', 'not_our_company_user', 'content', 'remark', 'file']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); $item['org_name'] = $org['name']; $item['dept_name'] = $dept['name']; $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; return $item; }) ->toArray(); } /** * @notes 获取安全事故数量 * @return int * @author likeadmin * @date 2023/12/19 14:28 */ public function count(): int { return SafetyAccident::where($this->searchWhere)->count(); } }