2017 © Pedro Peláez
 

library judge

Handle Role and Permission in Laravel

image

hchs/judge

Handle Role and Permission in Laravel

  • Wednesday, January 18, 2017
  • by g9308370
  • Repository
  • 1 Watchers
  • 1 Stars
  • 109 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 127 % Grown

The README.md

judge

Composer Package for Manage Roles and Permissions in Laravel., (*1)

Introduction

  • 80% complete
  • Version 0.21

Features

  1. Manage Role and Permission in different kinds of User Models (Authcatible Model).
  2. Create, Given, Remove, Delete and Check Permission.
  3. Create, Given, Remove, Delete and Check Role.

DEMO

  • Notyet

How To Use

Install

1.composer require, (*2)

    $ composer require hchs/judge       

2.add Service Provider in config/app.php, (*3)

    Hchs\Judge\JudgeServiceProvider::class    

3.run vendor:publish, (*4)

    $ php artisan vendor:publish --tag=migrations    

    $ php artisan vendor:publish --tag=config    

    // optional
    $ php artisan vendor:publish --tag=tests    

4.modify config file config/judge.php, (*5)

'models' => [
    'users' => 'App\User',  // set relation and namespace
    'fakeusers' => 'Hchs\Judge\Permission\FakeUser', // only for testing
]    

5.Auth Model extends Judge Abstract Class, (*6)

    <?php

    namespace App;

    use Illuminate\Notifications\Notifiable;
    use Hchs\Judge\Permission\AuthEloquent as Authenticatable;

    class User extends Authenticatable
    {
        use Notifiable;

        /**
         * The attributes that are mass assignable.
         *
         * @var array
         */
        protected $fillable = [
        'name', 'email', 'password',
        ];

        /**
         * The attributes that should be hidden for arrays.
         *
         * @var array
         */
        protected $hidden = [
        'password', 'remember_token',
        ];
    }

Basic Usage

    // use Role && Permission
    use Hchs\Judge\Permission\Role;
    use Hchs\Judge\Permission\Permission;

    // create Role & Permission
    $role = Role::create([
            'name' => 'admin',
            'display_name' => 'Admin',
            'description' => 'You are Admin'
    ]);
    $permission = Permission::create([
            'name' => 'create',
            'display_name' => 'Create Something',
            'description' => 'You can create something',
    ]);
    // Role attachPermission
    $role->attachPermission($permission);

    $user = User::find(1);

    // attachRole
    $user->attachRole($role);

    $user->hasRole('admin');  //true
    $user->hasRole('basic');  //false
    $user->hasPermission('create'); //true
    $user->hasPermission('delete'); //false

    // detachRole
    $user->detachRole($role);

    $user->hasRole('admin');  //false
    $user->hasRole('basic');  //false
    $user->hasPermission('create'); //false
    $user->hasPermission('delete'); //false

The Versions

18/01 2017

dev-master

9999999-dev

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

17/01 2017

0.2.2

0.2.2.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

17/01 2017

0.2.3

0.2.3.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

05/01 2017

0.2.1

0.2.1.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

05/01 2017

0.2.0

0.2.0.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

04/01 2017

0.1.9

0.1.9.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

03/01 2017

dev-develop

dev-develop

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

03/01 2017

0.1.8

0.1.8.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

01/01 2017

0.1.7

0.1.7.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

27/09 2016

0.1.6

0.1.6.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

27/09 2016

0.1.5

0.1.5.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

27/09 2016

0.1.4

0.1.4.0

Handle Role and Permission in Laravel

  Sources   Download

by Hchs

27/09 2016

0.1.3

0.1.3.0

Handle Role and Permission in Laravel

  Sources   Download

The Requires

 

The Development Requires

by Hchs

27/09 2016

0.1.1

0.1.1.0

Handle Role and Permission in Laravel

  Sources   Download

The Requires

 

The Development Requires

by Hchs

27/09 2016

0.1.0

0.1.0.0

Handle Role and Permission in Laravel

  Sources   Download

The Requires

 

The Development Requires

by Hchs