PHP code example of ajtarragona / acl

1. Go to this page and download the library: Download ajtarragona/acl 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/ */

    

ajtarragona / acl example snippets


    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => Ajtarragona\ACL\Models\User::class,
        ],
    ]

'model' => Ajtarragona\ACL\Models\User::class,

 ...
 'teams' => [
    'enabled' => true,
 ]
 ...

 'user_models' => [
 	'users' => 'Ajtarragona\ACL\Models\User',
 ],
 ...
 'models' => [
    /**
     * Role model
     */
    'role' => 'Ajtarragona\ACL\Models\Role',

    /**
     * Permission model
     */
    'permission' => 'Ajtarragona\ACL\Models\Permission',

    /**
     * Team model
     */
    'team' => 'Ajtarragona\ACL\Models\Team',

 ],

Route::group(['middleware' => ['role:admin']], function() { 
    ... 
});

Route::group(['middleware' => ['permission:edit-post']], function() { 
    ... 
});

@role('admin')
    <p>This is visible to users with the admin role. Gets translated to
    \Laratrust::hasRole('admin')</p>
@endrole

@permission('manage-admins')
    <p>This is visible to users with the given permissions. Gets translated to
    \Laratrust::can('manage-admins'). The @can directive is already taken by core
    laravel authorization package, hence the @permission directive instead.</p>
@endpermission
bash
php artisan vendor:publish --provider=Adldap\Laravel\AdldapAuthServiceProvider
bash
php artisan vendor:publish --tag="laratrust"
bash
php artisan ajtarragona:acl-setup
bash
php artisan vendor:publish --tag=ajtarragona-acl