PHP Class Spatie\Authorize\Middleware\Authorize

Show file Open project: spatie/laravel-authorize

Public Methods

Method Description
handle ( Illuminate\Http\Request $request, Closure $next, string | null $ability = null, string | null $boundModelName = null ) : mixed Handle an incoming request.

Protected Methods

Method Description
getModelFromRequest ( mixed $request, string $boundModelName ) : Model | null Get the model from the request using given boundModelName.
handleUnauthorizedRequest ( $request, string | null $ability = null, Model | null $model = null ) : Illuminate\Contracts\Routing\ResponseFactory | Illuminate\Http\RedirectResponse | Response Handle the unauthorized request.
hasRequiredAbility ( $user, string | null $ability = null, Model | null $model = null ) : boolean Determine if the currently logged in use has the given ability.

Method Details

getModelFromRequest() protected method

Get the model from the request using given boundModelName.
protected getModelFromRequest ( mixed $request, string $boundModelName ) : Model | null
$request mixed
$boundModelName string
return Illuminate\Database\Eloquent\Model | null

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

handleUnauthorizedRequest() protected method

Handle the unauthorized request.
protected handleUnauthorizedRequest ( $request, string | null $ability = null, Model | null $model = null ) : Illuminate\Contracts\Routing\ResponseFactory | Illuminate\Http\RedirectResponse | Response
$request
$ability string | null
$model Illuminate\Database\Eloquent\Model | null
return Illuminate\Contracts\Routing\ResponseFactory | Illuminate\Http\RedirectResponse | Symfony\Component\HttpFoundation\Response

hasRequiredAbility() protected method

Determine if the currently logged in use has the given ability.
protected hasRequiredAbility ( $user, string | null $ability = null, Model | null $model = null ) : boolean
$user
$ability string | null
$model Illuminate\Database\Eloquent\Model | null
return boolean