Reputation: 2364
Rather than using Route::get
, Route::post
etc for my controller requests I decided to use the Route::controller
method, really helps cut down on code lines in route.php
.
However I had previously set up some "route" names, for example my previous code included:
Route::get('admin/baserate/view', array('as' => 'baserateview','uses'=>'BaserateController@getView'));
but now I'm using Route::controller
I don't know how to implement the route alias name "baserateview". My new code looks like:
Route::controller('admin/baserate', 'BaserateController');
Is there any way I can do this?
Upvotes: 8
Views: 11336
Reputation: 350
You can do this in the following way:
// User Controller
Route::controller(
'users',
'AdminUserController',
array(
'getView' => 'admin.users.view',
'getEdit' => 'admin.users.edit',
'getList' => 'admin.users.list',
'getAdd' => 'admin.users.add',
'getUndelete' => 'admin.users.undelete',
'postDelete' => 'admin.users.delete'
)
);
Upvotes: 22
Reputation: 2364
Ok so it isn't possible to do it all on the Route:controller line. I'd have to go with both lines:
Route::controller('admin/baserate', 'BaserateController');
Route::get('admin/baserate/view', array('as' => 'baserateview','uses'=>'BaserateController@getView'));
...which works fine. I was just hoping that there would be a way to specify that one of the methods inside the controller has a named route without having to use two lines
Thanks anyway
Upvotes: -1