PHP code example of foothing / laravel-lock-routes
1. Go to this page and download the library: Download foothing/laravel-lock-routes 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::get('api/users', ['middleware:wrappr.check:admin.users', function() {
// Access is allowed for the users with the 'admin.users' permission
}]);
Route::get('api/users/{id?}', ['middleware:wrappr.check:read.users,user,1', function() {
// Access is allowed for the users with the 'read.users' permission on
// the 'user' resource with the {id} identifier
}]);
Route::get('api/users/{id?}', ['middleware:wrappr.check:read.users,user,{id}', function() {
// Access is allowed for the users with the 'read.users' permission on
// the 'user' resource with the {id} identifier
}]);
$this->provider = \App::make('Foothing\Wrappr\Providers\Permissions\PermissionProviderInterface');
// Returns all the user's permissions
$this->provider->user($user)->all();
// Returns all the role's permissions
$this->provider->role('admin')->all();
// Allow the user to edit post with id = 1
$this->provider->user($user)->grant('edit', 'post', 1);
// Revoke previous permission
$this->provider->user($user)->revoke('edit', 'post', 1);
// Return false.
$this->provider->check($user, 'edit', 'post', 1);