Route::controller( '/games', 'GameController', array(
'getRoflLol' => 'happy' // swapped
) );
use
php artisan routes
to check
that said I still think you should define everything, I've created app/routes/product.php
and include it into app/routes.php
an example
Route::group([
'namespace' => 'Uberous\Cms',
'prefix' => 'cms/product',
'before' => 'auth'
], function() {
Route::get('/', [
'as' => 'cms.product.index',
'uses' => 'ProductController@index'
]);
Route::get('create', [
'as' => 'cms.product.create',
'uses' => 'ProductController@create'
]);
Route::post('/', [
'as' => 'cms.product.store',
'before' => 'csrf',
'uses' => 'ProductController@store'
]);
Route::get('{id}/edit', [
'as' => 'cms.product.edit',
'uses' => 'ProductController@edit'
])->where('id', '[0-9]+');
Route::post('{id}', [
'as' => 'cms.product.update',
'before' => 'csrf',
'uses' => 'ProductController@update'
])->where('id', '[0-9]+');
Route::get('{id}/destroy', [
'as' => 'cms.product.destroy',
'uses' => 'ProductController@destroy'
])->where('id', '[0-9]+');
});
@zenry: I didn't think about creating a directory called "routes" before. It sounds like a good idea. Gonna do it now. Thanks Zenry! :)
Hi,
I'm not yet experienced with Laravel. It seems that experienced Laravel developpers recommand to avoid using Route::controller. Looks like a common pitfall for begginer (previous answer + http://philsturgeon.co.uk/blog/2013/07/beware-the-route-to-evil ) Route::controller looks pretty at first but it cames to problems in a short time (not possible to bind models, not possible to name routes (or maybe that's a lack in doc (or maybe i did not read it right)).
Am i wrong saying that ? (be smart, I'm a begginner)
I had this very same issue before, and zenry said the same thing. Always name your routes. I never thought of having a routes folder mind you, but my routes file on one of my projects is almost 400 or so lines. I use groups and Prefix a lot.
RixhersAjazi said:
I had this very same issue before, and zenry said the same thing. Always name your routes. I never thought of having a routes folder mind you, but my routes file on one of my projects is almost 400 or so lines. I use groups and Prefix a lot.
Yeah, that is why I didn't like to name everything in the routes file. But creating a routes directory and putting separate route files (one per each controller?) in it eliminates that issue.
SebSept said:
Hi,
I'm not yet experienced with Laravel. It seems that experienced Laravel developpers recommand to avoid using Route::controller. Looks like a common pitfall for begginer (previous answer + http://philsturgeon.co.uk/blog/2013/07/beware-the-route-to-evil ) Route::controller looks pretty at first but it cames to problems in a short time (not possible to bind models, not possible to name routes (or maybe that's a lack in doc (or maybe i did not read it right)).
Am i wrong saying that ? (be smart, I'm a begginner)
I am a newbie too; but I think it's all the better to avoid using it.
I must say @zenry that technique of yours made my routes file so much more easier to read. A lot more structured now. Went from about 400 lines of routes to less 70.
Thanks for the heads up.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community