Reputation: 489
I've been reading http://codehappy.daylerees.com and getting into Laravel gradually, but I stumbled upon some confusion after trying to get authentication working.
The examples on that site in the majority use closures and basically do a lot of things I personally do in controllers inside the routes.php
file. No problem, Laravel let's me use controllers and routes, however let's say I wish to restrict access to my admin panel in the routes. So don't let users go to http://example.com/admin
without first authenticating. The explanations cover that, but using closures/anonymous functions. So with closures it would look like this:
Route::get('admin', array('before' => 'auth', 'do' => function() {
// return admin view
}));
So I tried to use it the same way, but with a controller like this:
Route::get('admin', array('before' => 'auth', 'do' => 'admin_controller@index'));
Which results in a white page.
So my question is how can I forward the 'get' to a controller instead of handling it with a closure while still authenticating?
Upvotes: 0
Views: 132
Reputation: 12503
Use uses
instead of do
Route::get('admin', array('before' => 'auth', 'uses' => 'admin_controller@index'));
Upvotes: 2