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