If you are using the entrust library you can set the role specific things with an $user->hasRole('role') control structure.
thanks
how would you go about designing the directory structure?
A view directory per each user role with it's partials ?
Views/Admin/layouts Views/Member/layouts etc?
I attach "is" and "can" methods to my User object. So I can do things like:
Auth::user()->is('admin');
Auth::user()->can('manage users');
I also use a permissions filter:
Route::filter('permission', function ($route, $request, $permission) {
if (!Auth::user()->can($permission)) {
return Redirect::route('dashboard')
->with('flash_error', 'You do not have permission to view this page.');
}
}
);
You can use that filter in any routes or even do it in a resource controller as follows:
public function __construct()
{
parent::__construct();
$this->beforeFilter('permission:manage users');
}
In your views you can do something like this (for small projects):
@if(Auth::user()->can('manage users'))
{{-- Show menu item here --}}
@endif
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community