PHP code example of daltcore / permissions
1. Go to this page and download the library: Download daltcore/permissions 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/ */
daltcore / permissions example snippets
'permission' => \DALTCORE\Permissions\Http\Middleware\CheckPermission::class,
'role' => \DALTCORE\Permissions\Http\Middleware\CheckRole::class,
use DALTCORE\Permissions\Traits\Permissible;
Permission::addRole('admin');
Permission::addPermission('create-users', 'a small description');
Permission::addPermissionToRole('admin', 'create-users');
User::find(1)->giveRole('admin');
User::find(1)->hasRole('admin');
User::find(1)->hasPermission('create-users');
User::find(1)->dropRole('admin');
Permission::dropPermissionFromRole('admin', 'create-users');
Permission::removePermission('admin');
Permission::removeRole('admin');
Route::group(['middleware' => 'permission:create-users'], function () {
...
Route::group(['middleware' => 'role:admin'], function () {
php
DALTCORE\Permissions\ServiceProvider::class,
php
'Permission' => DALTCORE\Permissions\Facade::class,
bash
php artisan vendor:publish --tag=dpm-migrations
bash
php artisan migrate