PHP code example of merodiro / simple-admin

1. Go to this page and download the library: Download merodiro/simple-admin 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/ */

    

merodiro / simple-admin example snippets


protected $routeMiddleware = [
    ...
    'role'      => \Merodiro\SimpleRoles\Middleware\RoleMiddleware::class,        
];

$user->setRole('admin');

$user->removeRole();

if($user->hasRole('admin')){
    // do something
}

@role('admin')
    <h3>this is visible to admins only</h3>
@endrole

@role('admin')
    <h3>this is visible to admins only</h3>
@else
    <h3>this is visible to non admins only</h3>
@endrole

Route::get('/admin', function () {
    ...
})->middleware('role:admin');
bash
php artisan vendor:publish --provider="Merodiro\SimpleRoles\SimpleRolesServiceProvider"
bash
php artisan migrate