1. Go to this page and download the library: Download mirhamit/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/ */
mirhamit / acl example snippets
use MirHamit\ACL\HasPermissions;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasPermissions;
...
}
Route::get('test', function () {
return "salam";
})->middleware('role:test-role, test-permission');
Route::get('test', function () {
return "salam";
})->middleware('permission: test-permission');
@role('test-role')
// or @role(['test-role', 'test-role2'])
// user has role and can access to this section
@endrole
@permission('test-permission')
// or @permission(['test-permission', 'test-permission2'])
// user has role and can access to this section
@endpermission