1. Go to this page and download the library: Download mdsys/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/ */
Route::filter('acl', function($route, $request)
{
// we need this because laravel delete form sends POST request with {_method: 'DELETE'} as parameter
$method = $request->has('_method') ? $request->input('_method') : $request->server('REQUEST_METHOD');
if (!Acl::checkRoute($method, $request->server('REQUEST_URI'))) {
App::abort(403);
}
});
// Whether a user with ID 2 can see a list of all products
Acl::user(2)->permission('LIST_PRODUCTS')->check();
// Whether a user with ID 1 can edit product with ID 2
Acl::user(1)->permission('EDIT_PRODUCT', 2)->check();
// Can currently authenticated user edit product with ID 2
Acl::permission('EDIT_PRODUCT', 2)->check();
// Whether a user with ID 1 can edit and delete product with ID 2
Acl::user(1)->permission('EDIT_PRODUCT', 2)
->permission('DELETE_PRODUCT', 2)
->check();
// Can user with ID 1 access /products URL
Acl::user(1)->checkRoute('GET', '/products')
// Can currently authenticated user access /products URL
Acl::checkRoute('GET', '/products');
// Get me array of product IDs that user with ID 1 can edit
Acl::user(1)->permission('EDIT_PRODUCT')->getResourceIds();
// Get me array of product IDs that user with ID 1 can not edit
Acl::user(1)->permission('EDIT_PRODUCT')->getResourceIds(false);
'Acl' => 'VivifyIdeas\Acl\Facades\Acl',
php artisan acl:install
php artisan acl:update
php artisan acl:reset
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.