ldc-mesbr-app/app/Http/Requests/Contact/SearchContact.php
2025-08-05 14:47:02 +02:00

38 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests\Contact;
use App\Enums\UserRoles;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class SearchContact extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Auth::check() && (Auth::user()->roles === UserRoles::superadmin()->value || Auth::user()->roles === UserRoles::admin()->value);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'page' => 'sometimes|integer|nullable',
'searchName' => 'sometimes|alpha|max:50|nullable',
'searchFirstname' => 'sometimes|alpha|max:50|nullable',
'searchEmail' => 'sometimes|email|max:100|nullable',
'searchCp' => 'sometimes|integer|max:10|nullable',
'searchVille' => 'sometimes|alpha|max:50|nullable',
'searchCountry' => 'sometimes|integer|nullable',
];
}
}