1. Go to this page and download the library: Download kordy/auzo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// App\User.php
class User extends ...
{
use ..., Kordy\Auzo\Traits\HasRoleTrait;
...
/*
/*
|--------------------------------------------------------------------------
| Auzo Authorize Registrar
|--------------------------------------------------------------------------
|
| You may here add custom registrar where the Laravel Gate abilities are defined
|
*/
'registrar' => \Kordy\Auzo\Services\PermissionRegistrar::class,
/*
|--------------------------------------------------------------------------
| Auzo models paths
|--------------------------------------------------------------------------
|
| You may here add custom models paths to be used instead of models
// by ability instance
$role->givePermissionTo($ability);
// or by ability id
$role->givePermissionTo(3);
// or by array of abilities ids
$role->givePermissionTo([1,3]);
// or by ability name
$role->givePermissionTo('ability.name');
// remove permission by passing ability name
$role->removePermissionTo('ability.name');
$generator = new Kordy\Auzo\Services\GenerateAbilitiesToDB();
// generate only model CRUD abilities
$generator->modelAbilities($model)->saveModelToDB();
// generate only fields CRUD abilities
$generator->fieldsAbilities($model)->saveFieldsToDB();
// generate both model and fields CRUD abilities
$generator->fullCrudAbilities($model)->saveToDB();
bash
# create new role
php artisan auzo:role create 'testRole' --description='testing role'
# delete role
php artisan auzo:role delete 'testRole'
bash
# create new policy
php artisan auzo:policy create --name='Test Policy' --method='Controller@policy'
# delete policy by id
php artisan auzo:policy delete --id=1
bash
php artisan auzo:permission give 'testRole' 'ability.test,ability.test2' --policies='1,2:||'
bash
php artisan auzo:ability generate 'App\Post'
# or to generate only model abilities
php artisan auzo:ability generate 'App\Post' --option=model
# or to generate only fields abilities
php artisan auzo:ability generate 'App\Post' --option=fields
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.