Laravel - Authorization - Intercepting Gate Checks

Sometimes, you may wish to grant all abilities to a specific user. You may use the before method to define a closure that is run before all other authorization checks:

    
    use Illuminate\Support\Facades\Gate;
    
    Gate::before(function ($user, $ability) {
        if ($user->isAdministrator()) {
            return true;
        }
    });
	

If the before closure returns a non-null result that result will be considered the result of the authorization check.

You may use the after method to define a closure to be executed after all other authorization checks:

    
    Gate::after(function ($user, $ability, $result, $arguments) {
        if ($user->isAdministrator()) {
            return true;
        }
    });
	

Similar to the before method, if the after closure returns a non-null result that result will be considered the result of the authorization check.