Skip to content

Commit

Permalink
fix init command - on init append all existed permissions from databa…
Browse files Browse the repository at this point in the history
…se to admin role.
  • Loading branch information
moik.oleksandr committed Nov 15, 2021
1 parent b54f4fd commit e1d48dd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Commands/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace HexideDigital\ModelPermissions\Commands;

use App\Models\Role;
use HexideDigital\ModelPermissions\Classes\MigrateConfigs;
use HexideDigital\ModelPermissions\Models\Permission;
use HexideDigital\ModelPermissions\Models\Role;
use Illuminate\Console\Command;
use PermissionRelation;

Expand Down Expand Up @@ -45,9 +46,11 @@ public function handle()
$this->newLine();

$this->info('Creating startup permissions...');
$this->withProgressBar(config('modelPermissions.startup_permissions'), fn($table) => PermissionRelation::touch($table)->all());
$this->withProgressBar(config('modelPermissions.startup_permissions'), fn($table) => PermissionRelation::touch($table)->addCustom()->all());
$this->newLine();

Role::firstWhere('key', 'admin')->permissions()->sync(Permission::pluck('id'));

return self::SUCCESS;
}
}
21 changes: 21 additions & 0 deletions src/Seeders/PermissionRoleSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace HexideDigital\ModelPermissions\Seeders;

use App\Models\Role;
use App\Models\User;
use Artisan;
use Illuminate\Database\Seeder;

class PermissionRoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Artisan::call('model-permissions:init');
}
}

0 comments on commit e1d48dd

Please sign in to comment.