Support the ongoing development of →
Authentication Views Architecture
Last updated 1 year ago.

If you are using the entrust library you can set the role specific things with an $user->hasRole('role') control structure.

Last updated 1 year ago.


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?

Last updated 1 year ago.

I attach "is" and "can" methods to my User object. So I can do things like:

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()
    $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 --}}
Last updated 1 year ago.

thanks @orecrush, very useful

Last updated 1 year ago.

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

dflow dflow Joined 16 Sep 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.