<?php

namespace Modules\Settings\Database\Seeders;

use Illuminate\Database\Seeder;
use Modules\Core\Traits\HasModulePermissions;
use Modules\Auth\Models\Role;
use Modules\Core\Enums\RolesEnum;

class SettingsPermissionSeeder extends Seeder
{
    use HasModulePermissions;

    public function run(): void
    {
        $this->seedPermissions('settings', [
            'setting' => [
                'view',
                'manage',
            ],

            'app' => [
                'view',
                'update',
            ],
        ]);

        Role::where('name', RolesEnum::ADMIN->value)->first()?->givePermissionTo([
            'settings.setting.view',
            'settings.setting.manage',
            'settings.app.view',
            'settings.app.update',
        ]);

        // Assign view-only roles → view-only
        /* $viewOnly = ['settings.view', 'settings.app.view'];
        foreach ([RolesEnum::HR, RolesEnum::ACCOUNTS, RolesEnum::INVENTORY, RolesEnum::BILLINGS] as $role) {
            Role::where('name', $role->value)->first()?->givePermissionTo($viewOnly);
        } */
    }
}
