firmino / pry-acl
ACL package
1.1.1
2019-10-25 19:04 UTC
This package is not auto-updated.
Last update: 2024-11-02 19:31:52 UTC
README
Laravel ACL adds role to user auth.
Installation
Installation by composer require
composer require firmino/pry-acl
Installation manually, add in file composer.json
{
"require": {
"firmino/pry-acl": "1.0.*"
}
}
Publish the package configuration
php artisan vendor:publish --tag=config
Verify the configuration
<?php
return [
/**
* Name of table users
*/
'table_users' => 'users',
/**
* Define a prefix to tables of database application
*/
'table_prefix' => 'acl_'
];
Configuration laravel 5.5+
Laravel's package discovery will take care of integration for you.
Configuration laravel <5.5
Add the following settings to your app.php file.
'providers' => array(
//...
Firmino\UserAcl\Providers\UserAclServiceProvider::class,
),
and add aliases
'Acl' => Firmino\UerAcl\Facades\Acl::class
Working roles
//...ignore
use Firmino\UserAcl\Traits\Roles;
class User extends Model
{
use Roles;
//...ignore
$user = User::find(1);
$slug = 'admin';
$user->assignRole($slug');
$user->getRoles();
$user->revokeRole($slug);
$user->revokeAllRole();
Blade extensions
Allow viewing of certain content based on authenticated user role.
@role('admin')
<h1>I am Admin</h1>
@endrole
Facade
Import Facade Firmino\UserAcl\Facades\Acl
Create roles
/**
* Create a role
* @param array $data
* @return string
*/
Acl::createRole(
array(
'name' => 'Admin',
'slug' => 'admin',
'description' => ''
)
)
Delete Role
/**
* Delete a role with slug specify
* @param string $slug
* @return string
*/
Acl::deleteRole('admin')
Get Roles
/**
* Get all roles
* @return Collection
*/
Acl::roles()