Using a fluent names and parameters declaration in Partial Resource Routes

This commit is contained in:
Guillaume Briday 2018-03-28 11:10:26 +02:00
parent 9d7ed1140b
commit 0fa66a2f4c
1 changed files with 4 additions and 4 deletions

View File

@ -215,18 +215,18 @@ To quickly generate an API resource controller that does not include the `create
By default, all resource controller actions have a route name; however, you can override these names by passing a `names` array with your options:
Route::resource('photos', 'PhotoController', ['names' => [
Route::resource('photos', 'PhotoController')->names([
'create' => 'photos.build'
]]);
]);
<a name="restful-naming-resource-route-parameters"></a>
### Naming Resource Route Parameters
By default, `Route::resource` will create the route parameters for your resource routes based on the "singularized" version of the resource name. You can easily override this on a per resource basis by passing `parameters` in the options array. The `parameters` array should be an associative array of resource names and parameter names:
Route::resource('user', 'AdminUserController', ['parameters' => [
Route::resource('user', 'AdminUserController')->parameters([
'user' => 'admin_user'
]]);
]);
The example above generates the following URIs for the resource's `show` route: