Using a fluent names and parameters declaration in Partial Resource Routes
This commit is contained in:
parent
9d7ed1140b
commit
0fa66a2f4c
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in New Issue