PHP code example of enclave-code / static-auth-manager
1. Go to this page and download the library: Download enclave-code/static-auth-manager 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/ */
enclave-code / static-auth-manager example snippets
// If user has 'admin' or 'user' role
Route::group(['middleware' => ['role:admin|user']], function () {
//
})
// If user has 'admin' role
Route::group(['middleware' => ['role:admin']], function () {
//
})
// If user has 'user/create'
Route::group(['middleware' => ['permission:create/user']], function () {
//
})
// If user has 'user/create' or 'user/edit'
Route::group(['middleware' => ['permission:create/user|user/edit']], function () {
//
})
// config/permission.php
return [
/**
* DB Column name from model
*/
'column_name' => env('SAM_ROLE_COLUMN_NAME', 'role'),
/**
* Roles with permission as path
*
* - `*` Wildcard everything following
*
* 'admin' => [
* 'users/*',
* ],
* 'user' => [
* 'users/create'
* ]
*
*/
'roles' => [],
];
blade
@anypermission('user/edit|user/create')
Show if user has rights to user/edit OR user/create
@endanypermission
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.