Support the ongoing development of Laravel.io →
Requests Views Architecture
Last updated 2 years ago.
0
Route::controller( '/games', 'GameController', array(
    'getRoflLol' => 'happy' // swapped
) );

use

php artisan routes

to check

Last updated 2 years ago.
0
Solution

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]+');

});
Last updated 2 years ago.
0

@zenry: I didn't think about creating a directory called "routes" before. It sounds like a good idea. Gonna do it now. Thanks Zenry! :)

Last updated 2 years ago.
0

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)

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

budhajeewa budhajeewa Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.