PHP code example of osaris-uk / access

1. Go to this page and download the library: Download osaris-uk/access 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/ */

    

osaris-uk / access example snippets


use OsarisUk\Access\AccessTrait;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, AccessTrait;
}

Route::group(['middleware' => ['access:admin|moderator']], function () {
    //
});

Route::group(['middleware' => ['access:user']], function () {
    //
});

Route::group(['middleware' => ['access:user,create posts']], function () {
    //
});

Route::group(['middleware' => ['access:user,remove posts']], function () {
    //
});

Route::group(['middleware' => ['access:,edit posts']], function () {
    //
});

giveRoles(...$roles)
withdrawRoles(...$roles)
updateRoles(...$roles)
givePermissionTo(...$permissions)
withdrawPermissionTo(...$permissions)
updatePermissions(...$permissions)
hasRole(...$roles)
hasPermissionTo($permission)
bash
php artisan vendor:publish --provider="OsarisUk\Access\AccessServiceProvider" --tag="config"