1. Go to this page and download the library: Download laravarc/authorizer 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/ */
laravarc / authorizer example snippets
use Laravarc\Authorizer\Concerns\HasAuthorizerAbilities;
class User extends Authenticatable
{
use HasAuthorizerAbilities;
}
use Laravarc\Authorizer\Facades\Authorization;
use Laravarc\Authorizer\Facades\Role;
use App\Policies\CustomerPolicy;
Role::create('Accounting')->tenant($companyId)
->grant(CustomerPolicy::class)->only(['view', 'update']);
Role::create('Admin')->grant(CustomerPolicy::class); // all abilities
Authorization::role('Accounting')->grant(CustomerPolicy::class)->except(['delete']);
Authorization::user($user)->assignRole('Accounting');
Authorization::user($user)->allow(CustomerPolicy::class)->only(['export']);
use Laravarc\Authorizer\Contracts\TenantResolver;
$this->app->singleton(TenantResolver::class, CompanyTenantResolver::class);