Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
R

Roles Tool

This package is possibly abandoned. Please proceed with care.

Installation Instructions

A Laravel Nova tool to manage roles for Zeroplatform

zeroplatform roles

Installation

  1. You can install the nova tool in to a Laravel app that uses Nova via composer:
composer require zeroplatform/roles
  1. Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.
// in app/Providers/NovaServiceProvder.php

// ...

public function tools()
{
   return [
        // ...
        new \Zeroplatform\Roles\Roles,
    ];
}
  1. Add HasRoles trait to your user model:
// in app/User.php

// ...
class User extends Model {
    use \Zeroplatform\Roles\Traits\HasRoles;
    ...
}
  1. Optional, You can publish the config file with
php artisan vendor:publish --provider="Zeroplatform\Roles\ToolServiceProvider" --tag="config"
  1. Finally, run the migrations:
    php artisan migrate

Config

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'
        ],

    ],
];

Usage

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']);

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email itk.vtangel@gmail.com instead of using the issue tracker.

Credits

Support us

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.

License

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

Readme

Readme not found. Refer to the project website: https://github.com/vtangel/zeroplatform-roles

Screenshots

Back to Top
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.

Favorites

0 users favorited

Rating

N/A
(out of 5)
★★★★★
★★★★
★★★
★★
0 ratings

Author

Contributors

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas