1. Go to this page and download the library: Download am2studio/laravel-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/ */
$user->is('user'); // Checkes if user has user role
$user->is('admin|user'); // Checks if user has user OR admin role
$user->is('admin|user', true); // Checks if user has user AND admin role
$user->can('event.edit'); // Checkes if user has permission
$user->can('event.edit|event.create'); // Checks if user has event.edit OR event.create permission
$user->can('event.edit|event.create', true); // Checks if user has event.edit AND event.create permission
$p2 = Role::create([
'name' => 'Event edit',
'slug' => 'event.edit',
'description => '',
'model' => 'event',
]);
$p3 = Role::create([
'name' => 'Event edit',
'slug' => 'event.edit',
'description => '',
'model' => 'event',
'resource_id' => 1,
]);
$event = Event::find(1);
$user->attachPermisson($p2);
$user->attachPermisson($p3);
$user->allowed('event.edit', $event); // Checks if user has rights to Event model
$user->allowed('event.edit', $event, $event->id); // Checks if user has rights to Event model with selected id