You could:
- Extend the
Illuminate\Auth\Middleware\Authorizemiddleware - Override its
handlemethod and write your custom redirect logic - Modify your app's
App\Http\Kernel$routeMiddlewareproperty, so the'can'middleware points to your extended one.
or:
- Register an exception handling in your app's
App\Exceptions\Handler@registerclass method - Add a
renderableto handle theIlluminate\Auth\Access\AuthorizationException - Return a redirect response from this exception handler
More info on this second approach at the docs: https://laravel.com/docs/9.x/errors#rendering-exceptions