This package is DEPRECATED in favour of laravel-admin
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src Update and rename UserTrait.php to UserRoles.php Aug 24, 2015 Instructions updated Aug 24, 2015
composer.json package version changes Jul 21, 2015

Laravel Roles

Laravel 5 User Role Manager

The idea of this package came from laracast laracasts/Users-and-Roles-in-Laravel and now it is built for laravel 5.


Laravel >=5.1
PHP >= 5.5.9 


  1. Run

    composer require "appzcoder/laravel-roles":"dev-master"
  2. Add service provider into /config/app.php file.

    'providers' => [
  3. Publish migrations

    php artisan vendor:publish
  4. Run migrate command

    php artisan migrate
  5. Include UserRoles trait to your user model located at /app/User.php

    use Appzcoder\LaravelRoles\Traits\UserRoles;
    class User extends Model implements AuthenticatableContract, CanResetPasswordContract
        use Authenticatable, CanResetPassword, UserRoles;


Use the routes as bellow.

Route::get('/roles', function () {

    /* Create user if needed
    'name' => 'Sohel Amin',
    'email' => '',
    'password' => bcrypt('123456'),

    $user = App\User::first();

    /* Create roles
    $role = new Appzcoder\LaravelRoles\Models\Role;
    $role->name = 'admin';

    /* Assign and remove role from user
    $role = Appzcoder\LaravelRoles\Models\Role::whereName('admin')->first();

    return $user->roles;

Route::get('/admin', ['middleware' => 'role:admin', 'uses' => 'AdminController@index']);


Sohel Amin