Support the ongoing development of Laravel.io →
Requests IOC Blade
Last updated 2 years ago.
0

that is why you can name your routes ;)

http://laravel.io/bin/0zb4

last thing you want to do is go and change all your views, if you name your routes ( 'as' => 'name' ) you can move it all you want and not change your views

Last updated 2 years ago.
0

speaking of 'right ways', I think it's better to have a CircuitController instead of a CircuitsController

Last updated 2 years ago.
0

Thanks zenry, appreciate the reply.
I do normally name my routes but can't do that if you're using Route::controller or Route::resource. Guess I'll have to rethink for those methods.

Last updated 2 years ago.
0

A combination of zenry's reply and namespace grouping works much better.

Route::group(array('namespace' => 'Pitwall\Controllers'), function()
{
	Route::get('circuits', ['as' => 'circuits', 'uses' => 'CircuitController@index']);
	Route::get('circuit/{circuit}', ['as' => 'show_circuit', 'uses' => 'CircuitController@show']);

Now I wish I could decide whether a prefer \View or use View; Hmm....

Last updated 2 years ago.
0

out of curiosity, why did you namespace your controllers?

Last updated 2 years ago.
0

Ummm I'm not sure, I'm really learning the ropes at the moment.
With my models and repositories namespaced, it felt a bit strange still having my controllers still generically sat in app/controllers.

Last updated 2 years ago.
0

ChrisSoutham said:

Ummm I'm not sure, I'm really learning the ropes at the moment.
With my models and repositories namespaced, it felt a bit strange still having my controllers still generically sat in app/controllers.

as long as you remember that it's your app and that there is no absolute right way to do stuff. I 'never' namespace my controllers because I think it over complicates my app. Besides, my config is not namespaced, my routes are not namespaced, etc ;)

Last updated 2 years ago.
0

ChrisSoutham said:

Thanks zenry, appreciate the reply.
I do normally name my routes but can't do that if you're using Route::controller or Route::resource. Guess I'll have to rethink for those methods.

The names of Route::resource() are

Route::resource('example', 'ExampleController');

// Link to named routes from resource controller
{{ route('example.index') }}
{{ route('example.edit', $model->id) }}
Last updated 2 years ago.
0

Thanks eriktisme - didn't know that. Very handy :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.