From 39061c244d76d0b17f4cb56c780fc9937f4128af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 26 Feb 2026 19:27:15 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20[hr]=20=EC=82=AC=EB=B2=88=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=A0=9C=EA=B1=B0,=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=A0=9C=EA=B1=B0,=20=ED=87=B4=EC=A7=81?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Admin/HR/EmployeeController.php | 5 +- app/Models/HR/Employee.php | 12 ++-- app/Services/HR/EmployeeService.php | 15 ++--- resources/views/hr/employees/create.blade.php | 64 ++++--------------- resources/views/hr/employees/edit.blade.php | 20 +++--- .../hr/employees/partials/table.blade.php | 11 ++-- resources/views/hr/employees/show.blade.php | 12 ++-- 7 files changed, 48 insertions(+), 91 deletions(-) diff --git a/app/Http/Controllers/Api/Admin/HR/EmployeeController.php b/app/Http/Controllers/Api/Admin/HR/EmployeeController.php index 69b1939b..1de66c26 100644 --- a/app/Http/Controllers/Api/Admin/HR/EmployeeController.php +++ b/app/Http/Controllers/Api/Admin/HR/EmployeeController.php @@ -76,7 +76,6 @@ public function store(Request $request): JsonResponse 'name' => 'required|string|max:50', 'email' => 'nullable|email|max:100', 'phone' => 'nullable|string|max:20', - 'password' => 'nullable|string|min:6', 'department_id' => 'nullable|integer|exists:departments,id', 'position_key' => 'nullable|string|max:50', 'job_title_key' => 'nullable|string|max:50', @@ -85,8 +84,8 @@ public function store(Request $request): JsonResponse 'employee_status' => 'nullable|string|in:active,leave,resigned', 'manager_user_id' => 'nullable|integer|exists:users,id', 'display_name' => 'nullable|string|max:50', - 'employee_code' => 'nullable|string|max:30', 'hire_date' => 'nullable|date', + 'resign_date' => 'nullable|date', 'address' => 'nullable|string|max:200', 'emergency_contact' => 'nullable|string|max:100', ]; @@ -154,8 +153,8 @@ public function update(Request $request, int $id): JsonResponse 'employee_status' => 'nullable|string|in:active,leave,resigned', 'manager_user_id' => 'nullable|integer|exists:users,id', 'display_name' => 'nullable|string|max:50', - 'employee_code' => 'nullable|string|max:30', 'hire_date' => 'nullable|date', + 'resign_date' => 'nullable|date', 'address' => 'nullable|string|max:200', 'emergency_contact' => 'nullable|string|max:100', ]); diff --git a/app/Models/HR/Employee.php b/app/Models/HR/Employee.php index b576837b..9662e013 100644 --- a/app/Models/HR/Employee.php +++ b/app/Models/HR/Employee.php @@ -38,8 +38,8 @@ class Employee extends Model ]; protected $appends = [ - 'employee_code', 'hire_date', + 'resign_date', 'position_label', 'job_title_label', ]; @@ -67,16 +67,16 @@ public function manager(): BelongsTo // json_extra Accessor // ========================================================================= - public function getEmployeeCodeAttribute(): ?string - { - return $this->json_extra['employee_code'] ?? null; - } - public function getHireDateAttribute(): ?string { return $this->json_extra['hire_date'] ?? null; } + public function getResignDateAttribute(): ?string + { + return $this->json_extra['resign_date'] ?? null; + } + public function getAddressAttribute(): ?string { return $this->json_extra['address'] ?? null; diff --git a/app/Services/HR/EmployeeService.php b/app/Services/HR/EmployeeService.php index 011dd0dc..d5e12a53 100644 --- a/app/Services/HR/EmployeeService.php +++ b/app/Services/HR/EmployeeService.php @@ -24,7 +24,7 @@ public function getEmployees(array $filters = [], int $perPage = 20): LengthAwar ->with(['user', 'department']) ->forTenant($tenantId); - // 검색 필터 (이름, 사번, 이메일) + // 검색 필터 (이름, 이메일, 연락처) if (! empty($filters['q'])) { $search = $filters['q']; $query->where(function ($q) use ($search) { @@ -33,8 +33,7 @@ public function getEmployees(array $filters = [], int $perPage = 20): LengthAwar $uq->where('name', 'like', "%{$search}%") ->orWhere('email', 'like', "%{$search}%") ->orWhere('phone', 'like', "%{$search}%"); - }) - ->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(json_extra, '$.employee_code')) LIKE ?", ["%{$search}%"]); + }); }); } @@ -171,7 +170,7 @@ public function createEmployee(array $data): Employee 'name' => $data['name'], 'email' => $email, 'phone' => $data['phone'] ?? null, - 'password' => Hash::make($data['password'] ?? 'sam1234!'), + 'password' => Hash::make('sam1234!'), 'role' => 'ops', 'is_active' => true, 'must_change_password' => true, @@ -189,12 +188,12 @@ public function createEmployee(array $data): Employee // json_extra 구성 $jsonExtra = []; - if (! empty($data['employee_code'])) { - $jsonExtra['employee_code'] = $data['employee_code']; - } if (! empty($data['hire_date'])) { $jsonExtra['hire_date'] = $data['hire_date']; } + if (! empty($data['resign_date'])) { + $jsonExtra['resign_date'] = $data['resign_date']; + } if (! empty($data['address'])) { $jsonExtra['address'] = $data['address']; } @@ -244,7 +243,7 @@ public function updateEmployee(int $id, array $data): ?Employee ], fn ($v) => $v !== null); // json_extra 업데이트 - $jsonExtraKeys = ['employee_code', 'hire_date', 'address', 'emergency_contact', 'salary', 'bank_account']; + $jsonExtraKeys = ['hire_date', 'resign_date', 'address', 'emergency_contact', 'salary', 'bank_account']; $extra = $employee->json_extra ?? []; foreach ($jsonExtraKeys as $key) { if (array_key_exists($key, $data)) { diff --git a/resources/views/hr/employees/create.blade.php b/resources/views/hr/employees/create.blade.php index 8d5cd55e..b4b8e644 100644 --- a/resources/views/hr/employees/create.blade.php +++ b/resources/views/hr/employees/create.blade.php @@ -109,16 +109,6 @@ class="text-xs text-red-500 hover:text-red-700 font-medium shrink-0"> class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> - {{-- 사번 --}} -
- - -
- {{-- 이메일 / 연락처 --}}
@@ -135,17 +125,6 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
- {{-- 비밀번호 --}} -
- - -

미입력 시 기본 비밀번호가 설정됩니다.

-
- {{-- 근무 정보 --}}

근무 정보

@@ -205,14 +184,19 @@ class="shrink-0 w-9 h-9 flex items-center justify-center border border-gray-300
- {{-- 입사일 / 상태 --}} + {{-- 입사일 / 퇴직일 / 상태 --}}
-
+
-
+
+ + +
+
-
- {{-- 이메일 / 연락처 --}}
@@ -139,15 +131,21 @@ class="shrink-0 w-9 h-9 flex items-center justify-center border border-gray-300
- {{-- 입사일 / 상태 --}} + {{-- 입사일 / 퇴직일 / 상태 --}}
-
+
-
+
+ + +
+