<?php

namespace Database\Seeders\Global;

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

class BookingsRoleSeed extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $roles = Role::query()->whereIn('name', [
            'mtc',
            'Administrator',
            'Manager',
            'Editor',
        ])->get();

        /** @var Permission $model */
        $model = Permission::query()
            ->updateOrCreate([
                'name' => 'manage-bookings',
                'guard_name' => 'web'
            ]);
        $roles->each(fn(Role $role) => $role->givePermissionTo([$model]));
    }
}
