I have laravel 5.5 application and i use gates to authorise users. When the authorisation fails, the response is This action is unauthorized
How can i overwrite this response? I want to offer users a custom response.
The way i implemented it is by defining gates in AuthServiceProvider class and then using these gates with the middleware in my routes. In later laravel versions there is something like:
Gate::define('edit-settings', function ($user) {
return $user->isAdmin
? Response::allow()
: Response::deny('You must be a super administrator.');
});
But allow and deny methods don't exist in Laravel 5.5