43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class AssignClientsToGroupRequest 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.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'client_ids' => 'required|array|min:1',
|
|
'client_ids.*' => 'integer|distinct|exists:clients,id',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'client_ids.required' => 'La liste des clients est obligatoire.',
|
|
'client_ids.array' => 'La liste des clients doit être un tableau.',
|
|
'client_ids.min' => 'Veuillez sélectionner au moins un client.',
|
|
'client_ids.*.integer' => 'Chaque ID client doit être un entier.',
|
|
'client_ids.*.distinct' => 'Un client ne peut pas être envoyé plusieurs fois.',
|
|
'client_ids.*.exists' => 'Un ou plusieurs clients sélectionnés sont introuvables.',
|
|
];
|
|
}
|
|
}
|
|
|