62 lines
1.9 KiB
PHP
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', 'digits_between:1,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' => 'No. Telepon',
|
|
'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',
|
|
];
|
|
}
|
|
}
|