LaravelPackages.net
Acme Inc.
Toggle sidebar
leandreaci/laravel-permission

A Simple permission check to laravel.

373
0
0.0.3
About leandreaci/laravel-permission

leandreaci/laravel-permission is a Laravel package for a simple permission check to laravel.. It currently has 0 GitHub stars and 373 downloads on Packagist (latest version 0.0.3). Install it with composer require leandreaci/laravel-permission. Discover more Laravel packages by leandreaci or browse all Laravel packages to compare alternatives.

Last updated

Laravel Permission

Laravel 5.3

At the moment the package is not unit tested, but is planned to be covered later down the road.

Quick Installation

Begin by installing the package through Composer. The best way to do this is through your terminal via Composer itself:

composer require leandreaci\laravel-permission:dev-master

Or add to you composer.json and run composer install.

"require": {
   "Foo/Bar" : "*",
   "leandreaci/laravel-permission": "dev-master"
},

Once this operation is complete, simply add the service provider to your project's config/app.php file and run the provided migrations against your database.

Service Provider

Leandreaci\LaravelPermission\LaravelPermissionServiceProvider::class

in the providers array and

'Permission' => Leandreaci\LaravelPermission\Facade\LaravelPermission::class,

Migrations

You'll need to run the provided migrations against your database. Publish the migration files using the vendor:publish Artisan command and run migrate:

php artisan vendor:publish
php artisan migrate

Using

1 - Add permission slug to permissions table. 2 - Add user and permission equivalent to permission_user table. 3 - Add Authorizable Trait to your User Model( Example above: Laravel 5.3).

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Leandreaci\LaravelPermission\Traits\Authorizable;

class User extends Authenticatable
{
    use Notifiable;
    use Authorizable;

4 - Check any method of your controller


    use Leandreaci\LaravelPermission\Facade\Permission;

    class FooController
    {
        public function index()
        {
            if(! Permission::can('view.foo'))
            {
                //do what you want ;)
            }
        }
    }
Comments