buntan / roles by aanyszek

Simplest Roles
21
0
0
Package Data
Maintainer Username: aanyszek
Maintainer Contact: a.anyszek@linux.pl (Artur Anyszek)
Package Create Date: 2016-08-05
Package Last Update: 2018-09-25
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:10:43
Package Statistics
Total Downloads: 21
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' => [
    ...
    Aanyszek\Roles\RolesServiceProvider::class,
    ...
],

add to "\app\User.php":

...
use \Aanyszek\Roles\RolesTrait;
...

Usage

In route:

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

In seeder:

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

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

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