Skip to content

Create and manage permission and roles for your user !

License

Notifications You must be signed in to change notification settings

vassilidev/laraperm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create and manage permission and roles for your user !

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require vassilidev/laraperm

You can publish config and run the migrations with:

php artisan vendor:publish --provider="Vassilidev\Laraperm\LarapermServiceProvider"

This is the contents of the published config file:

return [
    'permissions' => [
        'super-admin' => env('LARAPERM_PERMISSION_SUPERADMIN', '*'),
    ]
];

Usage

Permission::create(['name' => 'edit posts']);

$role = Role::create(['name' => 'Publisher']);
$role->givePermissionTo('edit posts');

$user = User::factory()->create();
$publisher = User::factory()->create();

$user->declareAsSuperAdmin();
 $publisher->assignRole('Publisher');

dump($user->isSuperAdmin()); // True
dump($publisher->isSuperAdmin()); // False

dump($user->can('edit posts')); // True
dump($publisher->can('edit posts')); // True

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Create and manage permission and roles for your user !

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages