user(); return auth()->check() and $user->isAdmin(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'assign' => [ 'nullable', 'exists:users,id', // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed function ($attribute, $value, $fail) { /** @var \App\Models\User $user */ if ($user = User::whereId($value)->first() and !$user->isAdmin()) { $fail(trans('Cet utilisateur ne peut se voir assigner un ticket')); } } ] ]; } }