PHP code example of i74ifa / role-craft

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

    

i74ifa / role-craft example snippets


// config/role-craft.php

',          // exact class
    'App\Models\Billing\*',          // whole subtree
    '*\Public\*',                    // any "Public" folder anywhere
],

// config/role-craft.php

'excluded_models' => [
    App\Models\User::class,          // exact class
    'App\Models\Internal\*',         // every model under app/Models/Internal
    '*\Pivot\*',                     // any "Pivot" folder anywhere
],

class Post extends Model
{
    // Replaces the table-name segment in the permission name
    public $prefix_permissions = 'blog_posts';

    // Replaces the default action list for this model
    public $prefix_model_permissions = ['create', 'view', 'publish', 'archive'];
}
bash
php artisan vendor:publish --tag=role-craft-config
bash
php artisan role-craft:generate
bash
php artisan role-craft:sync manager --create
bash
php artisan role-craft:sync manager --models=User --models=Post

# OR Custom Directory
php artisan role-craft:sync manager --models=App\Models\Directory\User
bash
php artisan role-craft:sync manager --create