composer require zeroplatform/roles
tools method of the NovaServiceProvider.// in app/Providers/NovaServiceProvder.php
// ...
public function tools()
{
return [
// ...
new \Zeroplatform\Roles\Roles,
];
}
// in app/User.php
// ...
class User extends Model {
use \Zeroplatform\Roles\Traits\HasRoles;
...
}
php artisan vendor:publish --provider="Zeroplatform\Roles\ToolServiceProvider" --tag="config"
php artisan migrate
Config your settings in config/zeroplatform-roles.php
// in config/zeroplatform-roles.php
// ...
return [
/*
* Model class for User
*/
'user_model' => \App\User::class,
/*
* Resource class for User
*/
'user_resource' => \App\Nova\User::class,
/*
* Roles table name
*/
'roles_table_name' => 'zeroplatform_roles',
/*
* Model has roles table name
*/
'models_roles_table_name' => 'zeroplatform_models_roles',
/*
* Super users lists
*/
'super_users' => [
/*
* Field name to check for super users
*/
'field' => 'email',
/*
* Values to check for super users
*/
'values' => [
'itk.vtangel@gmail.com'
]
],
/*
* Permissions
*/
'permissions' => [
[
// Permission name
'name' => 'permission_name',
// Label to display
'label' => 'Example permissions',
// Group of permissions
'group' => 'Permission group'
],
],
];
You can test if a user has a permission:
$user->hasPermissionTo('edit products');
You can test if a user has Any of an array of permissions:
$user->hasAnyPermission(['edit posts', 'delete posts']);
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email itk.vtangel@gmail.com instead of using the issue tracker.
Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
The MIT License (MIT). Please see License File for more information.
Readme not found. Refer to the project website: https://github.com/vtangel/zeroplatform-roles
| Added | 7 years ago |
This package should be on the Packagist API but we're not getting any results.
Please note that the Packagist cache is pretty long, so some times you just need to check back in an hour.