logobinder / roles by logobinder

Simplest Roles
24
0
0
Package Data
Maintainer Username: logobinder
Maintainer Contact: logobinder@gmail.com (Artur Anyszek)
Package Create Date: 2016-08-04
Package Last Update: 2016-08-04
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:13:49
Package Statistics
Total Downloads: 24
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

roles

Simple add trait to user model to use roles. Contains role middleware.

Instalation:

add to "\config\app.php":

'providers' => [
    ...
    Logobinder\Roles\RolesServiceProvider::class,
    ...
],

add to "\app\User.php":

...
use \Logobinder\Roles\RolesTrait;
...

Usage

In route:

Route::group(['namespace' => 'Admin', 'middleware' => ['web', 'auth','role:admin'], 'prefix' => 'admin'], function () {
    Route::resource('some', 'SomeController');
});

In seeder:

    $role = Logobinder\Roles\Role::create(['name' => 'admin']);

    $user = \App\User::create([
                'name' => 'Administrator',
                'email' => 'a.anyszek@gmail.com',
                'password' => bcrypt('adminadmin'),
    ]);

    $user->roles()->attach($role);