diff --git a/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php b/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php index d2c427d43df7..2822540a8594 100644 --- a/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php +++ b/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php @@ -86,7 +86,7 @@ public function authorizeResource($model, $parameter = null, array $options = [] $middleware = []; foreach ($this->resourceAbilityMap() as $method => $ability) { - $modelName = in_array($method, ['index', 'create', 'store']) ? $model : $parameter; + $modelName = in_array($method, $this->methodsWithoutModels()) ? $model : $parameter; $middleware["can:{$ability},{$modelName}"][] = $method; } @@ -112,4 +112,14 @@ protected function resourceAbilityMap() 'destroy' => 'delete', ]; } + + /** + * Get the list of resource methods which not wait for a parameter. + * + * @return array + */ + protected function methodsWithoutModels() + { + return ['index', 'create', 'store']; + } }