WIP RBAC
This commit is contained in:
parent
7ed6a0b0c6
commit
9dc58f9f92
18
app/Models/Enums/Permission.php
Normal file
18
app/Models/Enums/Permission.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Enums;
|
||||
|
||||
enum Permission: string
|
||||
{
|
||||
case StudyMetadataView = 'study_metadata_view';
|
||||
case StudyMetadataEdit = 'study_metadata_edit';
|
||||
case StudyDownload = 'study_download';
|
||||
case StudyDelete = 'study_delete';
|
||||
case StudyArchive = 'study_archive';
|
||||
case ReportCreate = 'report_create';
|
||||
case ReportDownload = 'report_download';
|
||||
case StudyNotesCreate = 'study_notes_create';
|
||||
case StudyNotesView = 'study_notes_view';
|
||||
case AttachmentUpload = 'attachment_upload';
|
||||
case AttachmentDownload = 'attachment_download';
|
||||
}
|
@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
RoleSeeder::class,
|
||||
InstituteSeeder::class,
|
||||
UserSeeder::class,
|
||||
]);
|
||||
|
44
database/seeders/RoleSeeder.php
Normal file
44
database/seeders/RoleSeeder.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Enums\Permission;
|
||||
use App\Models\Enums\UserRole;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission as SpatiePermission;
|
||||
use Spatie\Permission\Models\Role as SpatieRole;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$adm = SpatieRole::create(['name' => UserRole::Admin->name]);
|
||||
$rad = SpatieRole::create(['name' => UserRole::Radiologist->name]);
|
||||
$tech = SpatieRole::create(['name' => UserRole::Technician->name]);
|
||||
$guest = SpatieRole::create(['name' => UserRole::Guest->name]);
|
||||
|
||||
foreach (Permission::cases() as $perm) {
|
||||
SpatiePermission::create(['name' => $perm->value]);
|
||||
}
|
||||
|
||||
$rad->givePermissionTo([
|
||||
Permission::ReportCreate,
|
||||
Permission::StudyDownload,
|
||||
Permission::StudyMetadataView,
|
||||
Permission::StudyNotesCreate,
|
||||
Permission::StudyNotesView,
|
||||
Permission::AttachmentDownload,
|
||||
]);
|
||||
|
||||
$tech->givePermissionTo([
|
||||
Permission::StudyDownload,
|
||||
Permission::StudyMetadataView,
|
||||
Permission::StudyMetadataEdit,
|
||||
Permission::StudyNotesCreate,
|
||||
Permission::StudyNotesView,
|
||||
Permission::AttachmentUpload,
|
||||
Permission::AttachmentDownload,
|
||||
Permission::StudyArchive,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user