$params['unit_qualification_id'], 'name' => $params['name'], 'id_card' => $params['id_card'], 'technical_title' => $params['technical_title'], 'job' => $params['job'], 'qualification_name_one' => $params['qualification_name_one'], 'certification_body_one' => $params['certification_body_one'], 'qualification_number_one' => $params['qualification_number_one'], 'get_date_one' => !empty($params['get_date_one']) ? strtotime($params['get_date_one']) : 0, 'effective_date_one' => !empty($params['effective_date_one']) ? strtotime($params['effective_date_one']) : 0, 'qualification_one_status' => $params['qualification_one_status'], 'qualification_name_two' => $params['qualification_name_two'], 'certification_body_two' => $params['certification_body_two'], 'qualification_number_two' => $params['qualification_number_two'], 'get_date_two' => !empty($params['get_date_two']) ? strtotime($params['get_date_two']) : 0, 'effective_date_two' => !empty($params['effective_date_two']) ? strtotime($params['effective_date_two']) : 0, 'qualification_two_status' => $params['qualification_two_status'], 'remark' => $params['remark'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'create_user' => $admin_id, ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑工程监理--安全管理人员 * @param array $params * @return bool * @author likeadmin * @date 2024/02/26 11:30 */ public static function edit(array $params): bool { Db::startTrans(); try { SupervisionSafetyManagementPersonnel::where('id', $params['id'])->update([ 'unit_qualification_id' => $params['unit_qualification_id'], 'name' => $params['name'], 'id_card' => $params['id_card'], 'technical_title' => $params['technical_title'], 'job' => $params['job'], 'qualification_name_one' => $params['qualification_name_one'], 'certification_body_one' => $params['certification_body_one'], 'qualification_number_one' => $params['qualification_number_one'], 'get_date_one' => !empty($params['get_date_one']) ? strtotime($params['get_date_one']) : 0, 'effective_date_one' => !empty($params['effective_date_one']) ? strtotime($params['effective_date_one']) : 0, 'qualification_one_status' => $params['qualification_one_status'], 'qualification_name_two' => $params['qualification_name_two'], 'certification_body_two' => $params['certification_body_two'], 'qualification_number_two' => $params['qualification_number_two'], 'get_date_two' => !empty($params['get_date_two']) ? strtotime($params['get_date_two']) : 0, 'effective_date_two' => !empty($params['effective_date_two']) ? strtotime($params['effective_date_two']) : 0, 'qualification_two_status' => $params['qualification_two_status'], 'remark' => $params['remark'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'update_time' => time(), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除工程监理--安全管理人员 * @param array $params * @return bool * @author likeadmin * @date 2024/02/26 11:30 */ public static function delete(array $params): bool { return SupervisionSafetyManagementPersonnel::destroy($params['id']); } /** * @notes 获取工程监理--安全管理人员详情 * @param $params * @return array * @author likeadmin * @date 2024/02/26 11:30 */ public static function detail($params): array { $data = SupervisionSafetyManagementPersonnel::withoutField('update_time,delete_time')->findOrEmpty($params['id']); $unit_qualification = SupervisionParticipatingUnitsQualifications::field('company_id')->where('id',$data['unit_qualification_id'])->findOrEmpty(); $company = SupervisionParticipatingUnits::field('unit_name')->where('id',$unit_qualification['company_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); $data['company_name'] = $company['unit_name']; $data['create_user_name'] = $admin['name']; $data['qualification_one_status_text'] = $data->qualification_one_status_text; $data['qualification_two_status_text'] = $data->qualification_two_status_text; return $data->toArray(); } }