As per laravel official documentation,
if the after callback returns a non-null result that result will be considered the result of the check.
But when I declare after callback and overwrite the value as false, it still returns the previous value.
What am I missing? How to override the value in Gate::after ?
Gate::define('edit-settings', function ($user = null) {
return true;
});
Gate::after(function ($user = null, $ability = null, $result = null, $arguments = null) {
return false; //this have no effect
});
// ------------
Gate::allows('edit-settings'); // return true!
Gate::after(function ($user = null, $ability = null, $result = null, $arguments = null)
- params should not be null. I think it can cause this error