2017 © Pedro Peláez
 

library acl-laravel

A simple and complete Control Panel with ACL for Laravel >= 5.5

image

crebs86/acl-laravel

A simple and complete Control Panel with ACL for Laravel >= 5.5

  • Saturday, July 7, 2018
  • by crebs86
  • Repository
  • 0 Watchers
  • 1 Stars
  • 11 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Fisrt register these services.

On a fresh laravel ">=5.5.*" installation., (*1)

composer require crebs86/acl-laravel:0.9

Now run codes bellow:

Step 1) Publish views and migrations, (*2)

php artisan vendor:publish --tag=first --force 

Step 2) Migrate databases and seed, (*3)

composer dumpautoload
php artisan migrate
php artisan db:seed

Step 3) Publish Classes, (*4)

php artisan vendor:publish --tag=second --force

Now register middlewares on app/Http/Kernel.php

    protected $routeMiddleware = [
    //... laravel codes
        'access' => \Crebs86\Acl\Middleware\Access::class,
        'active' => \Crebs86\Acl\Middleware\Activated::class,
    ];

For protect your controllers insert on:

You may call the middleware method from the controller's constructor., (*5)

class MyExemploController extends Controller{
        public function __construct()
        {
            $this->middleware('auth');      //if auth is necessary
            $this->middleware('access');    //if email verification is necessary
            $this->middleware('active');    //if active account is necessary
        }
}

Protecting methods:

Method Acl::can(array|string, boolean);, (*6)

First parameter: array or string, noo default value; set permissions needed., (*7)

Second parameter: boolean; default true. If the method protected require a super administrator user., (*8)

use Crebs86\Acl\Facades\Acl;

class MyExempleController extends Controller{

        public function myMethod()
        {
            Acl::can('permission_name', false);
            //continue...
        }

        public function methodRequireSuperAdminUser()
        {
            Acl::can('permission_name', true);  //for require only super-admin users can access the method define second parameter like true
            //continue...
        }

        public function multiPermission()
        {
              Acl::can(['permission_name', 'other_permission'], false);  //for multi permissions set permissions like a array
              //continue...
        }
}

Similarly, you can use the helpers:

class MyExempleController extends Controller{

        public function myMethod()
        {
            have('permission_name', false);
            //continue...
        }

        public function methodRequireSuperAdminUser()
        {
            if(can('permission_name', true)):
                //continue...
            else:
                abort(403,'Access Denied');
            endif    
        }

        public function multiPermission()
        {
              have(['permission_name', 'other_permission'], false);
              //continue...
        }
}

On Blade files

@if(can(['permission_name', 'other_permission'], false))
    <p>You can view this</p>
@else:
    <p>You don't have permission</p>
@endif

After installation

http://localhost/login

E-mail: super-admin@your.app, (*9)

Password: crebsacl, (*10)

You should change the email address and pass., (*11)

Tanks!, (*12)

Tanks!, (*13)

The Versions

07/07 2018

dev-master

9999999-dev https://github.com/crebs86/acl-lavarel

A simple and complete Control Panel with ACL for Laravel >= 5.5

  Sources   Download

MIT

The Requires

 

by Avatar crebs86

laravel acl auth roles permission control panel

04/07 2018

0.9

0.9.0.0 https://github.com/crebs86/acl-lavarel

A simple and complete Control Panel with ACL for Laravel >= 5.5

  Sources   Download

MIT

The Requires

 

by Avatar crebs86

laravel acl auth roles permission control panel