<?php

namespace App\Services\TenantBootstrap\Steps;

use App\Services\TenantBootstrap\Contracts\TenantBootstrapStep;
use Illuminate\Support\Facades\DB;

class SettingsStep implements TenantBootstrapStep
{
    public function key(): string
    {
        return 'settings_seed';
    }

    public function run(int $tenantId): void
    {
        if (! DB::getSchemaBuilder()->hasTable('settings')) {
            return;
        }

        $pairs = [
            ['general.company_name', '회사명 미설정'],
            ['ui.theme', 'light'],
            ['inventory.auto_reserve', '0'],
        ];
        foreach ($pairs as [$key,$val]) {
            DB::table('settings')->updateOrInsert(
                ['tenant_id' => $tenantId, 'key' => $key],
                ['value' => $val, 'updated_at' => now(), 'created_at' => now()]
            );
        }
    }
}
