From e55df2cd4f6ff9f8fab01d26367847041bb8a528 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 19 Jun 2026 21:13:03 +0700 Subject: [PATCH] feat: update EmployeeRequest validation rules to require join_date, base_salary, and employment_status only for non-owners; enhance EmployeeForm.vue to reflect required fields in the UI --- app/Http/Requests/Admin/Hr/EmployeeRequest.php | 8 ++++---- resources/js/components/admin/hr/EmployeeForm.vue | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Requests/Admin/Hr/EmployeeRequest.php b/app/Http/Requests/Admin/Hr/EmployeeRequest.php index 2e29b04..6e83490 100644 --- a/app/Http/Requests/Admin/Hr/EmployeeRequest.php +++ b/app/Http/Requests/Admin/Hr/EmployeeRequest.php @@ -25,7 +25,7 @@ public function authorize(): bool */ public function rules(): array { - $anyEmployee = ! empty($this->join_date) || ! empty($this->employment_status) || ! empty($this->base_salary); + $isOwner = $this->role === Role::OWNER->value; return [ 'email' => ['required', 'email', 'max:100', Rule::unique('users', 'email')->ignore($this->route('user')?->id)], @@ -35,9 +35,9 @@ public function rules(): array 'gender' => ['nullable', Rule::enum(Gender::class)], 'birth_date' => ['nullable', 'date', 'before:today'], 'address' => ['nullable', 'string'], - 'join_date' => [$anyEmployee ? 'required' : 'nullable', 'date'], - 'employment_status' => [$anyEmployee ? 'required' : 'nullable', Rule::enum(EmploymentStatus::class)], - 'base_salary' => [$anyEmployee ? 'required' : 'nullable', 'integer', 'min:0'], + 'join_date' => [Rule::requiredIf(! $isOwner), 'date'], + 'employment_status' => [Rule::requiredIf(! $isOwner), Rule::enum(EmploymentStatus::class)], + 'base_salary' => [Rule::requiredIf(! $isOwner), 'integer', 'min:0'], 'role' => ['required', Rule::in(Role::assignableValues())], ]; } diff --git a/resources/js/components/admin/hr/EmployeeForm.vue b/resources/js/components/admin/hr/EmployeeForm.vue index be07f61..5f30833 100644 --- a/resources/js/components/admin/hr/EmployeeForm.vue +++ b/resources/js/components/admin/hr/EmployeeForm.vue @@ -181,18 +181,18 @@ function submit() {
- Tanggal Bergabung + Tanggal Bergabung - Gaji Pokok + Gaji Pokok - Status Kepegawaian + Status Kepegawaian