PHP code example of sweet1s / moonshine-roles-permissions
1. Go to this page and download the library: Download sweet1s/moonshine-roles-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/ */
sweet1s / moonshine-roles-permissions example snippets
namespace App\Models;
use Sweet1s\MoonshineRBAC\Traits\HasMoonShineRolePermissions;
use Spatie\Permission\Models\Role as SpatieRole;
class Role extends SpatieRole
{
use HasMoonShineRolePermissions;
protected $with = ['permissions'];
}
namespace App\Models;
// ...
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Sweet1s\MoonshineRBAC\Traits\MoonshineRBACHasRoles;
class User extends Authenticatable
{
use MoonshineRBACHasRoles;
const SUPER_ADMIN_ROLE_ID = 1;
// ...
}
namespace App\MoonShine\Resources;
use Sweet1s\MoonshineRBAC\Traits\WithPermissionsFormComponent;
use Sweet1s\MoonshineRBAC\Traits\WithRolePermissions;
class RoleResource extends ModelResource
{
use WithRolePermissions;
use WithPermissionsFormComponent;
// ...
}
namespace App\MoonShine\Resources;
use Sweet1s\MoonshineRBAC\Traits\WithRoleFormComponent;
use Sweet1s\MoonshineRBAC\Traits\WithRolePermissions;
class UserResource extends ModelResource
{
use WithRolePermissions;
use WithRoleFormComponent;
// ...
}