1. Go to this page and download the library: Download rivalex/clearance 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/ */
rivalex / clearance example snippets
use Rivalex\Clearance\Traits\HasClearance;
class User extends Authenticatable
{
use HasClearance; //
// Does the user have this permission in this context?
$user->canIn('orders-create', $store);
// Alias - mirrors Spatie's hasPermissionTo() naming
$user->hasPermissionIn('orders-create', $store);
// Does the user hold this role in this context?
$user->hasRoleIn('manager', $store);
// Optionally filter by guard
$user->canIn('orders-create', $store, 'api');
$user->hasRoleIn('manager', $store, 'web');
use Rivalex\Clearance\Services\ContextService;
$service = app(ContextService::class);
$service->canIn($user, 'orders-create', $store);
$service->hasPermissionIn($user, 'orders-create', $store); // alias
$service->hasRoleIn($user, 'manager', $store);
$service->resolveFor($user, $store); // Collection of all effective permission names
Clearance::canIn($user, 'orders-create', $store);
Clearance::resolveFor($user, $store);
Clearance::guards(); // names of all managed authentication guards
use Rivalex\Clearance\Models\UserRoleContext;
// Samuele is "StoreStaff" only within Alessandro's Store
UserRoleContext::create([
'user_id' => $samuele->id,
'role_id' => $staffRole->id,
'context_type' => Store::class,
'context_id' => $store->id,
]);