<?php

namespace Database\Seeders\Global;

use Illuminate\Database\Seeder;
use Mtc\MercuryDataModels\Permission;
use Mtc\MercuryDataModels\Role;

class ContentMigrationPermissionSeed extends Seeder
{
    public function run()
    {
        $roles = Role::query()->whereIn('name', ['mtc', 'Administrator'])->get();

        /** @var Permission $permission */
        $permission = Permission::query()
            ->updateOrCreate([
                'name' => 'migrate-content',
                'guard_name' => 'web',
            ]);

        $roles->each(fn (Role $role) => $role->givePermissionTo([$permission]));
    }
}
