From 65b13eb0470b5b61d48544f8ba19ef4b0fbafcc2 Mon Sep 17 00:00:00 2001 From: Nasir Khan Saikat Date: Wed, 15 May 2024 14:42:11 +0600 Subject: [PATCH] + --- .../Auth/PermissionRoleTableSeeder.php | 37 +++++++++++-------- tests/Feature/BackendViewSuperAdminTest.php | 4 +- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/database/seeders/Auth/PermissionRoleTableSeeder.php b/database/seeders/Auth/PermissionRoleTableSeeder.php index 148d3d723..cf84612c7 100644 --- a/database/seeders/Auth/PermissionRoleTableSeeder.php +++ b/database/seeders/Auth/PermissionRoleTableSeeder.php @@ -19,6 +19,26 @@ class PermissionRoleTableSeeder extends Seeder */ public function run() { + $this->CreateDefaultPermissions(); + + /** + * Create Roles and Assign Permissions to Roles. + */ + $super_admin = Role::create(['id' => '1', 'name' => 'super admin']); + + $admin = Role::create(['id' => '2', 'name' => 'administrator']); + $admin->givePermissionTo(['view_backend', 'edit_settings']); + + $manager = Role::create(['id' => '3', 'name' => 'manager']); + $manager->givePermissionTo('view_backend'); + + $executive = Role::create(['id' => '4', 'name' => 'executive']); + $executive->givePermissionTo('view_backend'); + + $user = Role::create(['id' => '5', 'name' => 'user']); + } + + public function CreateDefaultPermissions() { // Create Permissions $permissions = Permission::defaultPermissions(); @@ -26,6 +46,7 @@ public function run() $permission = Permission::make(['name' => $permission]); $permission->saveOrFail(); } + echo "\n Default Permissions Created. \n"; Artisan::call('auth:permissions', [ 'name' => 'posts', @@ -48,21 +69,5 @@ public function run() echo "\n _Comments_ Permissions Created."; echo "\n\n"; - - /** - * Create Roles and Assign Permissions to Roles. - */ - $super_admin = Role::create(['id' => '1', 'name' => 'super admin']); - - $admin = Role::create(['id' => '2', 'name' => 'administrator']); - $admin->givePermissionTo(['view_backend', 'edit_settings']); - - $manager = Role::create(['id' => '3', 'name' => 'manager']); - $manager->givePermissionTo('view_backend'); - - $executive = Role::create(['id' => '4', 'name' => 'executive']); - $executive->givePermissionTo('view_backend'); - - $user = Role::create(['id' => '5', 'name' => 'user']); } } diff --git a/tests/Feature/BackendViewSuperAdminTest.php b/tests/Feature/BackendViewSuperAdminTest.php index 019628b71..0a47b16b1 100644 --- a/tests/Feature/BackendViewSuperAdminTest.php +++ b/tests/Feature/BackendViewSuperAdminTest.php @@ -20,9 +20,9 @@ protected function setUp(): void parent::setUp(); // seed the database - // $this->seed(); + $this->seed(); - Artisan::call('db:seed'); + // Artisan::call('db:seed'); Artisan::call('laravel-starter:insert-demo-data'); // Get Super Admin