bunta / roles
Simplest Roles
v1.1.0
2018-09-25 08:32 UTC
This package is auto-updated.
Last update: 2024-11-15 00:17:48 UTC
README
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);