2017 © Pedro Peláez
 

library permission

Permissions for Laravel 5.6

image

solarios/permission

Permissions for Laravel 5.6

  • Thursday, May 3, 2018
  • by dastin
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

Solarios Permission

A very simple permission package for Laravel 5.6. Includes roles and permissions., (*1)

You can install the package via composer:, (*2)

``` bash composer require solarios/permission, (*3)


Because Laravel >= 5.5 uses auto-disover, the service provider will automatically register. If you want to include it manually, do so in the `config/app.php` file. ```php 'providers' => [ // ... Solarios\Permission\PermissionServiceProvider::class, ];

Usage

The packages comes with 2 traits:, (*4)

  • HasPermissions
  • HasRoles

HasPermissions

The hasPermissionTo() method checks if the model has a permission. If the model also uses roles, it will also check the role for the permission., (*5)

$user->givePermissionTo('manage users');

$user->hasPermissionTo('manage users');
// Returns: true

Or when there is a role 'admin' with the 'manage users' permission:, (*6)

$user->giveRole('admin');
// The admin role has the 'manage users' permission.

$role->hasPermissionTo('manage users');
// Returns: true

Remove a permission, (*7)

$user->revokePermissionTo('manage users');

Hasroles

Use this trait to give a model roles., (*8)

$user->giveRole('editor');

$user->hasRole('editor');
// Returns: true

Remove a role, (*9)

$user->revokeRole('editor');

Relations

Roles and permissions both have a polymorphic relation so we are not bound to one (user) model., (*10)

The Versions

03/05 2018

dev-master

9999999-dev

Permissions for Laravel 5.6

  Sources   Download

MIT

The Requires

 

by Jurre

02/05 2018

0.1

0.1.0.0

Permissions for Laravel 5.6

  Sources   Download

MIT

The Requires

 

by Jurre