PHP code example of despark / laravel-permission-roles
1. Go to this page and download the library: Download despark/laravel-permission-roles 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/ */
despark / laravel-permission-roles example snippets
Route::filter('admin.permission', function () {
$route = explode('/', \Route::getCurrentRoute()->getPath());
if (!Auth::user()->can('edit_'.str_replace('-', '_', array_get($route, 1)))) {
throw new \Exception("Sorry, you don't have permission to access this page.");
}
});