$params['uid'], 'remark' => $params['remark'] ?? '', 'admin_id' => $admin_id, 'lead_admin_id' => $params['lead_admin_id'], 'connect_uids' => $params['connect_uids'], 'connect_id' => $params['connect_id'], 'connect_time' => !empty($params['connect_time']) ? strtotime($params['connect_time']) : 0, 'quit_time' => !empty($params['quit_time']) ? strtotime($params['quit_time']) : 0, ]); Admin::where('id',$params['uid'])->update(['status'=>2]); 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/05/23 09:43 */ public static function edit(array $params,$admin_id): bool { Db::startTrans(); try { OaPersonalQuit::where('id', $params['id'])->update([ 'uid' => $params['uid'], 'remark' => $params['remark'] ?? '', 'admin_id' => $admin_id, 'lead_admin_id' => $params['lead_admin_id'], 'connect_uids' => $params['connect_uids'], 'connect_id' => $params['connect_id'], 'connect_time' => !empty($params['connect_time']) ? strtotime($params['connect_time']) : 0, 'quit_time' => !empty($params['quit_time']) ? strtotime($params['quit_time']) : 0, ]); 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/05/23 09:43 */ public static function delete(array $params): bool { return OaPersonalQuit::destroy($params['id']); } /** * @notes 获取离职档案详情 * @param $params * @return array * @author likeadmin * @date 2024/05/23 09:43 */ public static function detail($params): array { $data = OaPersonalQuit::findOrEmpty($params['id']); $user = Admin::where('id',$data['uid'])->findOrEmpty(); $other_user = Admin::where('id','in',[$data['lead_admin_id'],$data['connect_id']])->column('name','id'); $connect_users = Admin::where('id','in',$data['connect_uids'])->column('name'); $data['user_name'] = $user['name']; $data['lead_admin_name'] = $other_user[$data['lead_admin_id']] ?? ''; $data['connect_user_name'] = $other_user[$data['connect_id']] ?? ''; $data['connect_users'] = implode(',',$connect_users); return $data->toArray(); } }