PHP code example of weirdo / dynamic-acl

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

    

weirdo / dynamic-acl example snippets


composer 

php artisan vendor:publish

php artisan migrate

php artisan make:admin --role

use Weirdo\DynamicAcl\Models\Role;

$user->roles()->sync([1, 2, 3,...]);

$user->roles()->get();

auth()->user()->hasPermission('admin.articles.create');

auth()->user()->hasPermission('admin.articles.*')

$user->hasPermission('admin.articles.update', $article);

// Or with a custom relation_key (default is 'user_id')
$user->hasPermission('admin.articles.update', $article, 'owner_id');

$user->isOwner($article);

// Or with a custom relation_key
$user->isOwner($article, 'owner_id');

// Or pass it as ['model' => id]
$user->isOwner(['article' => $article->id]);

// Or with a custom model path
$user->isOwner(['App\\Article' => $article->id]);