Modifying Laravel 4 resource controller routes
I just started developing with Laravel and I really understand why it's
such a popular framework. Having been a PHP-developer for many years now
I've been bothered with how loose the language is. Using Laravel fixes
many of those issues and helps me create structured code.
Today I began working with resource controllers and resource routes and it
works great. Although, I'd like to modify some of the automatically
generated routes and I'm not certain if this is in fact possible or not.
This is the scenario, I have a model called Workspace (using Eloquent) and
I created a resource controller using artisan.
php artisan controller:make WorkspaceController
And I also added the routes using this command in my routes.php file.
Route::resource('workspace',
'PROJECT\Controllers\Workspaces\WorkspaceController');
Now to my issue. Since I want to use getIndex to list the available
resources I'd like the index route to be workspaces and not workspace,
whereas I'd like to keep the structure for other scenarios like
workspace/{id}/edit and so on.
Do you guys know how I can modify the default routes that Route::resource
creates?
I'd be very grateful if anyone cares to help me with this one :)
Thanks in advance! // Jonathan
No comments:
Post a Comment