Trying to prevent non-admin users from accessing certain pages. I must not be doing it correctly though because I'm getting back an error of undefined offset: 1
while trying to access an admin only page while logged in as an admin.
Filter
Route::filter('admin', function()
{
if (!Auth::user() || Auth::user()->permissions != 1) return Redirect::to('/');
});
Routes
Route::resource('deals', 'DealsController');
Route::resource('blog', 'PostsController');
Route::group(array('before' => 'admin'), function()
{
Route::get('deals/create', 'DealsController');
Route::get('blog/create', 'PostsController');
});
I can't put the filter on a constructor of my deals or blog controller because the index page for each of those routes needs to be accessible to all users. When I'm not logged is as an admin, the routes function correctly and redirect back to the home page when trying to visit a page that is admin-only. Thanks for any insights.