original_string: 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);
          }
      }
code: 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);
          }
      }
code_tokens: 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 ) ; } }
docstring: 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
docstring_tokens: Authorize a resource action based on the incoming request .