One (simple) option would be to use the Auth::check()
function to see if they are logged in:
Route::get('/', function()
{
if (Auth::check())
{
return 'logged in!';
}
else
{
return 'not logged in!';
}
});
You would be able to use the same logic in the controller if you so wish.
EDIT - using filters
If you wanted to do this in the filter, you could use something like this:
Route::filter('auth', function()
{
if (Auth::guest())
{
return Redirect::to('non-admin-home');
}
});
and then defining a second route (or action in your controller) to handle the normal users. Though this would mean a different url for the page, which I don't think is what you want..
COMPLETE CONTROLLER-BASED ROUTING FLOW: (keeping routes.php
clean)
routes.php
Route::controller('/', 'IndexController');
IndexController.php
class IndexController extends BaseController
{
// HOME PAGE
public function getIndex()
{
if (Auth::check())
{
return View::make('admin.home');
}
else
{
return View::make('user.home');
}
}
}