Spatie\Authorize\Middleware\Authorize::handle PHP Method

handle() public method

Handle an incoming request.
public handle ( Illuminate\Http\Request $request, Closure $next, string | null $ability = null, string | null $boundModelName = null ) : mixed
$request Illuminate\Http\Request
$next Closure
$ability string | null
$boundModelName string | null
return mixed
    public function handle($request, Closure $next, $ability = null, $boundModelName = null)
    {
        $model = $this->getModelFromRequest($request, $boundModelName);
        if (!$this->hasRequiredAbility($request->user(), $ability, $model)) {
            return $this->handleUnauthorizedRequest($request, $ability, $model);
        }
        return $next($request);
    }