2017 © Pedro Peláez
 

library laravel-permission-manager

Laravel Permission Manager

image

joshbrw/laravel-permission-manager

Laravel Permission Manager

  • Friday, September 8, 2017
  • by joshbrw
  • Repository
  • 1 Watchers
  • 1 Stars
  • 686 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 40 % Grown

The README.md

Laravel Permission Manager

This package provides a simple way of registering permissions, organising them by group and then retrieving all permissions. These permissions can then be assigned to User/Role entities and used for Access Control logic., (*1)

Installation

  1. Install the package using composer require joshbrw/laravel-permission-manager
  2. If you're using Laravel 5.5 this is all that is required, the package will automatically load its' own Providers and Facades. If you're using Laravel 5.4, read on.
  3. Then register the Service Provider in config/app.php to ensure that the container bindings etc are loaded: 'providers' => [ ... Joshbrw\LaravelPermissions\LaravelPermissionManagerServiceProvider::class, ]
  4. You can then optionally register the Permissions facade if you'd rather use Permission::registerPermissions() rather than using the PermissionManager directly: 'aliases' => [ ... 'Permissions' => Joshbrw\LaravelPermissions\Facades\Permissions::class, ]
  5. You are now installed!

Registering Permissions

Permissions should usually be registered in the boot() method ophpuf a Service Provider - this ensures that this package has been able to register itself using it's own register() method first., (*2)

Using the Facade

The simplest way of registering permissions is using the Permissions facade. The following example registers the user.list and user.create permissions within the User group:, (*3)

use Permissions;
use Joshbrw\LaravelPermissions\Permission;

class MyProvider extends ServiceProvider {
    public function boot()
    {
        Permissions::register('User', [
            new Permission('user.list', 'List Users', 'This allows a User to list other Users.'),
            new Permission('user.create', 'Create Users', 'This allows a User to create another User.'),
        ]);
    }
}

Using the Trait

You can also use the RegistersPermissions trait if you're not a fan of Facades, for example:, (*4)

use Joshbrw\LaravelPermissions\Traits\RegistersPermissions;
use Joshbrw\LaravelPermissions\Permission;

class MyProvider extends ServiceProvider {
    use RegistersPermissions;

    public function boot()
    {
        $this->registerPermissions('User', [
            new Permission('user.list', 'List Users', 'This allows a User to list other Users.'),
            new Permission('user.create', 'Create Users', 'This allows a User to create another User.'),
        ]);
    }
}

The Versions

08/09 2017

dev-master

9999999-dev

Laravel Permission Manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Josh Brown

08/09 2017

v0.1.1

0.1.1.0

Laravel Permission Manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Josh Brown

08/09 2017

v0.1

0.1.0.0

Laravel Permission Manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Josh Brown