$params['unit_qualification_id'], 'name' => $params['name'], 'work_type' => $params['work_type'], 'id_card' => $params['id_card'], 'validity_period' => !empty($params['validity_period']) ? strtotime($params['validity_period']) : 0, 'enter_time' => !empty($params['enter_time']) ? strtotime($params['enter_time']) : 0, 'leave_time' => !empty($params['leave_time']) ? strtotime($params['leave_time']) : 0, 'status' => $params['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:45 */ public static function edit(array $params): bool { Db::startTrans(); try { SupervisionSpecialOperationPersonnel::where('id', $params['id'])->update([ 'unit_qualification_id' => $params['unit_qualification_id'], 'name' => $params['name'], 'work_type' => $params['work_type'], 'id_card' => $params['id_card'], 'validity_period' => !empty($params['validity_period']) ? strtotime($params['validity_period']) : 0, 'enter_time' => !empty($params['enter_time']) ? strtotime($params['enter_time']) : 0, 'leave_time' => !empty($params['leave_time']) ? strtotime($params['leave_time']) : 0, 'status' => $params['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:45 */ public static function delete(array $params): bool { return SupervisionSpecialOperationPersonnel::destroy($params['id']); } /** * @notes 获取工程监理--特种作业人员资质详情 * @param $params * @return array * @author likeadmin * @date 2024/02/26 11:45 */ public static function detail($params): array { $data = SupervisionSpecialOperationPersonnel::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['status_text'] = $data->status_text; return $data->toArray(); } }