This commit is contained in:
Dr Masroor Ehsan 2024-12-31 21:58:21 +06:00
parent 7ed6a0b0c6
commit 9dc58f9f92
3 changed files with 63 additions and 0 deletions

View 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';
}

View File

@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
public function run(): void public function run(): void
{ {
$this->call([ $this->call([
RoleSeeder::class,
InstituteSeeder::class, InstituteSeeder::class,
UserSeeder::class, UserSeeder::class,
]); ]);

View 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,
]);
}
}