1. Go to this page and download the library: Download programic/permissions 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/ */
programic / permissions example snippets
use Illuminate\Foundation\Auth\User as Authenticatable;
use Programic\Permission\Traits\HasPermissions;
use Programic\Permission\Traits\HasRole;
class User extends Authenticatable
{
use HasPermissions;
use HasRole;
// ...
}
use Illuminate\Database\Eloquent\Model;
use Programic\Permission\Traits\HasEntityPermissions;
class Article extends Model
{
use HasEntityPermissions;
// ...
}
// Assign global role to user
$user->assignRole('writer');
// Assign target specific role to user
$user->assignRole('writer', $model);
// Adding global permission to role
$role->givePermission('view-article');