Using Laravel 4 and Sentry. I have a CRUD admin system that managers and admins can access. I want managers to have access to all CRUD operations except for DELETE. I know that I can add a line such as
@if (Sentry::check())
in my view to ensure the user is logged in, but don't know how to check that they are an admin.
I have the following filter
Route::filter('auth.admin', function()
{
$user = Sentry::getUser();
$admin = Sentry::findGroupByName('Admins');
if (!$user->inGroup($admin)) return Redirect::to('admin/login');
});
Easy way:
if (Sentry::getUser()->isSuperUser())
// or
if (Sentry::hasPermission('superuser')) // or admin or whatever permission you want
or excplicitly:
if (Sentry::hasPermission('delete'))