Вход Регистрация
Файл: gapps/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/Authorize.php
Строк: 60
<?php

namespace IlluminateFoundationHttpMiddleware;

use 
Closure;
use 
IlluminateContractsAuthAccessGate;

class 
Authorize
{
    
/**
     * The gate instance.
     *
     * @var IlluminateContractsAuthAccessGate
     */
    
protected $gate;

    
/**
     * Create a new middleware instance.
     *
     * @param  IlluminateContractsAuthAccessGate  $gate
     * @return void
     */
    
public function __construct(Gate $gate)
    {
        
$this->gate $gate;
    }

    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @param  string  $ability
     * @param  string|null  $model
     * @return mixed
     *
     * @throws IlluminateAuthAccessAuthorizationException
     */
    
public function handle($requestClosure $next$ability$model null)
    {
        
$this->gate->authorize($ability$this->getGateArguments($request$model));

        return 
$next($request);
    }

    
/**
     * Get the arguments parameter for the gate.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  string|null  $model
     * @return array|string|IlluminateDatabaseEloquentModel
     */
    
protected function getGateArguments($request$model)
    {
        
// If there's no model, we'll pass an empty array to the gate. If it
        // looks like a FQCN of a model, we'll send it to the gate as is.
        // Otherwise, we'll resolve the Eloquent model from the route.
        
if (is_null($model)) {
            return [];
        }

        if (
strpos($model'\') !== false) {
            return $model;
        }

        return $request->route($model);
    }
}
Онлайн: 1
Реклама