1. Go to this page and download the library: Download putheng/role 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/ */
putheng / role example snippets
Putheng\Role\RoleServiceProvider::class,
php artisan migrate
use Putheng\Role\Traits\HasPermissionsTrait;
class User extends Model {
use HasPermissionsTrait;
}
use Putheng\Role\Models\Permission;
Permission::get()->map(function($permission){
Gate::define($permission->name, function($user) use ($permission){
return $user->hasPermissionTo($permission);
});
});
'role' => \Putheng\Role\RoleMiddleware::class,
Route::group(['middleware' => 'role:admin'], function () {
Route::group(['middleware' => 'role:admin,delete users'], function () {
Route::get('/admin/users', function () {
return 'Delete users in admin panel';
});
});
Route::get('/admin', function () {
return 'Admin panel';
});
});