New-Thanasoft/thanasoft-back/app/Http/Requests/UpdateEmployeeRequest.php
nyavokevin 56b0c50111 feat(auth): add employee user linking and password setup flow
Add user management endpoints and link employees to existing users
through `user_id`, including API resources, validation, repository
support, and database migrations.

Introduce a two-step login flow that checks email first and lets users
without a password create one before signing in.

Update the employee detail UI with a dedicated user tab and refresh the
employee and intervention side navigation to support the new account
management flow.
2026-04-08 13:31:57 +03:00

68 lines
2.5 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateEmployeeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true; // Add your authorization logic here
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
'first_name' => 'nullable|string|max:191',
'last_name' => 'nullable|string|max:191',
'email' => [
'nullable',
'email',
'max:191',
Rule::unique('employees', 'email')->ignore($this->route('employee'))
],
'phone' => 'nullable|string|max:50',
'user_id' => 'nullable|exists:users,id',
'job_title' => 'nullable|string|max:191',
'hire_date' => 'nullable|date',
'active' => 'boolean',
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'first_name.required' => 'Le prénom est obligatoire.',
'first_name.string' => 'Le prénom doit être une chaîne de caractères.',
'first_name.max' => 'Le prénom ne peut pas dépasser :max caractères.',
'last_name.required' => 'Le nom de famille est obligatoire.',
'last_name.string' => 'Le nom de famille doit être une chaîne de caractères.',
'last_name.max' => 'Le nom de famille ne peut pas dépasser :max caractères.',
'email.email' => 'L\'adresse email doit être valide.',
'email.unique' => 'Cette adresse email est déjà utilisée.',
'phone.string' => 'Le téléphone doit être une chaîne de caractères.',
'phone.max' => 'Le téléphone ne peut pas dépasser :max caractères.',
'user_id.exists' => 'L\'utilisateur sélectionné est invalide.',
'job_title.string' => 'L\'intitulé du poste doit être une chaîne de caractères.',
'job_title.max' => 'L\'intitulé du poste ne peut pas dépasser :max caractères.',
'hire_date.date' => 'La date d\'embauche doit être une date valide.',
'active.boolean' => 'Le statut actif doit être un booléen.',
];
}
}