<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        $defaults = [
            'business_name' => 'Wash&Wear',
            'business_logo' => null,
            'landing_badge' => 'Sepatu kotor? Chill, kami handle.',
            'landing_title' => 'Sneakers balik fresh, outfit auto naik level.',
            'landing_subtitle' => 'Wash&Wear bikin sepatu harian, putih, suede, sampai limited pair kamu lebih bersih, wangi, dan siap dipakai lagi tanpa drama.',
            'landing_whatsapp_text' => 'Halo Wash&Wear, mau tanya laundry sepatu dong.',
            'landing_footer' => 'Keep it clean. Keep it wearable.',
            'landing_hero_image' => 'landing/wash-wear-hero.png',
        ];
        $now = now();

        foreach ($defaults as $key => $value) {
            DB::table('app_settings')->updateOrInsert(
                ['branch_id' => null, 'key' => $key],
                ['value' => json_encode($value), 'created_at' => $now, 'updated_at' => $now],
            );
        }
    }

    public function down(): void
    {
        DB::table('app_settings')->whereIn('key', [
            'landing_badge',
            'landing_title',
            'landing_subtitle',
            'landing_whatsapp_text',
            'landing_footer',
            'landing_hero_image',
        ])->delete();
    }
};
