2017 © Pedro Peláez
 

library laroles

A light permission management for Laravel.

image

zehirpx/laroles

A light permission management for Laravel.

  • Thursday, December 1, 2016
  • by zehirpx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 11 % Grown

The README.md

la-roles

A light permission management for Laravel., (*1)

Requirements

  • Laravel >= 5.0

Installation

To get started, install the package via the Composer package manager:, (*2)

composer require zehirpx/laroles

Next, register the service provider in the providers array of your config/app.php:, (*3)

zehirpx\Laroles\LarolesServiceProvider::class,

Now, publish and migrate the migrations:, (*4)

php artisan vendor:publish
php artisan migrate

After running the commands, addd the zehirpx\Laroles\HasRoles trait to your App\User model. The trait will provide a few method to your model which allow you inspect the roles and permissions of the user., (*5)

<?php

namespace App;

use zehirpx\Laroles\HasRoles;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasRoles;
}

Quickstart

Create a role

You can create a role by using the create method of the RoleRepository:, (*6)

$roles = new zehirpx\Laroles\RoleRepository;

$roles->create('customer-support', 'Customer Support', [
            'create-servers', 'update-servers']);

Assign roles to a User

You can assign or re-assign roles for a user by using the updateUserRoles method of the RoleRepository:, (*7)

$roles->updateUserRoles($user, ['customer-support']);

Note: A user can be assigned to multiple roles., (*8)

Check permissions on a User

Since we have used the HasRoles trait to the App\User model, so we can use the rolesCan method to check if the user's roles has the given permission., (*9)

$user->rolesCan('update-servers');      // true
$user->rolesCan('delete-servers');      // false

Note: The roleCan method will checking on all the roles that assigned to the user., (*10)

Check permissions on a Role

You may also wish to check for the permissions on a Role model by using the can method of the model:, (*11)

$role->can('create-servers');       // true
$role->can('delete-servers');       // false

The Versions

01/12 2016

dev-master

9999999-dev

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

01/12 2016

v0.1.6

0.1.6.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

07/11 2016

v0.1.5

0.1.5.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

07/11 2016

v0.1.4

0.1.4.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

07/11 2016

v0.1.3

0.1.3.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

07/11 2016

v0.1.2

0.1.2.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

26/10 2016

v0.1.1

0.1.1.0

A light permission management for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel role management permission authority

26/10 2016

v0.1.0

0.1.0.0

A light permission management for Laravel.

  Sources   Download

The Requires

 

The Development Requires

laravel role management permission authority