Skip to content

Commit

Permalink
Updates AuthorizationGivePermissionsToRolesSeeder_3.php to use role m…
Browse files Browse the repository at this point in the history
…odel from config (apiato#681)

- Role model was hard coded and that was ignoring, customized  role model which spetie package allows
- Simple update to use role model as specified in configuration file, instead using directly
  • Loading branch information
smurtazakazmi authored Jun 4, 2022
1 parent 8ccc422 commit 99811cb
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

use App\Containers\AppSection\Authorization\Tasks\GetAllPermissionsTask;
use App\Ship\Parents\Seeders\Seeder as ParentSeeder;
use Spatie\Permission\Models\Role;

class AuthorizationGivePermissionsToRolesSeeder_3 extends ParentSeeder
{
public function run(): void
{
// Give all permissions to 'admin' role on all Guards ----------------------------------------------------------------
$adminRoleName = config('appSection-authorization.admin_role');
$roleModel = config('permission.models.role');
foreach (array_keys(config('auth.guards')) as $guardName) {
$allPermissions = app(GetAllPermissionsTask::class)->whereGuard($guardName)->run(true);
$adminRole = Role::findByName($adminRoleName, $guardName);
$adminRole = $roleModel::findByName($adminRoleName, $guardName);
$adminRole->givePermissionTo($allPermissions);
}

Expand Down

0 comments on commit 99811cb

Please sign in to comment.