dstpabuaran.com/app/Http/Requests/Admin/HR/EmployeeRequest.php
Yoga Pangestu bc810c93d2 feat: enhance Employee management with filtering options and improved data handling
- Updated EmployeeController to accept request filters for employment status, activity status, and gender.
- Modified EmployeeService to support filtering in the getAll method.
- Enhanced Employee index page with a filter toolbar for better user experience.
- Fixed route parameter naming for employee-related routes.
- Added comprehensive tests for employee index functionality and filtering capabilities.
2026-07-30 11:26:11 +07:00

62 lines
1.9 KiB
PHP

<?php
namespace App\Http\Requests\Admin\HR;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class EmployeeRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$userId = $this->route('user')?->id;
return [
'email' => [
'required',
'email',
'max:100',
Rule::unique('users', 'email')->ignore($userId, 'id'),
],
'username' => [
'required',
'string',
'max:20',
'alpha_dash',
Rule::unique('users', 'username')->ignore($userId, 'id'),
],
'full_name' => ['required', 'string', 'max:200'],
'phone_number' => ['nullable', 'string', 'max:20'],
'gender' => ['nullable', 'in:male,female'],
'birth_date' => ['nullable', 'date'],
'address' => ['nullable', 'string'],
'join_date' => ['required', 'date'],
'resign_date' => ['nullable', 'date', 'after_or_equal:join_date'],
'employment_status' => ['required', Rule::in(['full_time', 'part_time', 'contract', 'internship', 'resigned'])],
'base_salary' => ['required', 'integer', 'min:0'],
];
}
public function attributes(): array
{
return [
'email' => 'Email',
'username' => 'Username',
'full_name' => 'Nama Lengkap',
'phone_number' => 'Nomor HP',
'gender' => 'Jenis Kelamin',
'birth_date' => 'Tanggal Lahir',
'address' => 'Alamat',
'join_date' => 'Tanggal Masuk',
'resign_date' => 'Tanggal Keluar',
'employment_status' => 'Status Kepegawaian',
'base_salary' => 'Gaji Pokok',
];
}
}