public function authorizeResource($model, $parameter = null, array $options = [], $request = null)
    {
        $parameter = $parameter ?: Str::snake(class_basename($model));

        $middleware = [];

        foreach ($this->resourceAbilityMap() as $method => $ability) {
            $modelName = in_array($method, $this->resourceMethodsWithoutModels()) ? $model : $parameter;

            $middleware["can:{$ability},{$modelName}"][] = $method;
        }

        foreach ($middleware as $middlewareName => $methods) {
            $this->middleware($middlewareName, $options)->only($methods);
        }
    }
public function authorizeResource($model, $parameter = null, array $options = [], $request = null)
    {
        $parameter = $parameter ?: Str::snake(class_basename($model));

        $middleware = [];

        foreach ($this->resourceAbilityMap() as $method => $ability) {
            $modelName = in_array($method, $this->resourceMethodsWithoutModels()) ? $model : $parameter;

            $middleware["can:{$ability},{$modelName}"][] = $method;
        }

        foreach ($middleware as $middlewareName => $methods) {
            $this->middleware($middlewareName, $options)->only($methods);
        }
    }
public function authorizeResource ( $ model , $ parameter = null , array $ options = [ ] , $ request = null ) { $ parameter = $ parameter ? : Str :: snake ( class_basename ( $ model ) ) ; $ middleware = [ ] ; foreach ( $ this -> resourceAbilityMap ( ) as $ method => $ ability ) { $ modelName = in_array ( $ method , $ this -> resourceMethodsWithoutModels ( ) ) ? $ model : $ parameter ; $ middleware [ "can:{$ability},{$modelName}" ] [ ] = $ method ; } foreach ( $ middleware as $ middlewareName => $ methods ) { $ this -> middleware ( $ middlewareName , $ options ) -> only ( $ methods ) ; } }
Authorize a resource action based on the incoming request.

@param  string  $model
@param  string|null  $parameter
@param  array  $options
@param  \Illuminate\Http\Request|null  $request
@return void
Authorize a resource action based on the incoming request .