that is why you can name your routes ;)
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
speaking of 'right ways', I think it's better to have a CircuitController
instead of a CircuitsController
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.
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....
out of curiosity, why did you namespace your controllers?
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.
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 ;)
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) }}
Thanks eriktisme - didn't know that. Very handy :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community