Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
nasirkhan committed May 15, 2024
1 parent 6faf430 commit 65b13eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
37 changes: 21 additions & 16 deletions database/seeders/Auth/PermissionRoleTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,34 @@ 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();

foreach ($permissions as $permission) {
$permission = Permission::make(['name' => $permission]);
$permission->saveOrFail();
}
echo "\n Default Permissions Created. \n";

Artisan::call('auth:permissions', [
'name' => 'posts',
Expand All @@ -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']);
}
}
4 changes: 2 additions & 2 deletions tests/Feature/BackendViewSuperAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65b13eb

Please sign in to comment.