vernova/app/Http/Requests/StoreEmployeeRequest.php
2026-07-26 19:58:27 +03:30

59 lines
2.1 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreEmployeeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'first_name' => 'required|string|max:100',
'last_name' => 'required|string|max:100',
'national_code' => 'nullable|string|max:20',
'phone' => 'nullable|string|max:20',
'email' => 'nullable|email|max:255',
'contract_type' => 'required|in:full_time,part_time,contractor,intern,consultant',
'base_salary' => 'nullable|numeric|min:0',
'currency_id' => 'nullable|exists:currencies,id',
'bank_account' => 'nullable|string|max:50',
'hire_date' => 'required|date',
'termination_date' => 'nullable|date|after_or_equal:hire_date',
'position' => 'nullable|string|max:100',
'department' => 'nullable|string|max:100',
'project_id' => 'nullable|exists:projects,id',
'notes' => 'nullable|string',
'status' => 'nullable|in:active,inactive,terminated,on_leave',
'job_title' => 'nullable|string|max:100',
];
}
/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'first_name.required' => __('employee.validation_first_name_required'),
'last_name.required' => __('employee.validation_last_name_required'),
'contract_type.required' => __('employee.validation_contract_type_required'),
'contract_type.in' => __('employee.validation_contract_type_invalid'),
'hire_date.required' => __('employee.validation_hire_date_required'),
'base_salary.numeric' => __('employee.validation_base_salary_numeric'),
'termination_date.after_or_equal' => __('employee.validation_termination_date_after'),
];
}
}