<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('store_settings', function (Blueprint $table) {
            $table->id();
            $table->string('key')->unique();
            $table->text('value')->nullable();
            $table->timestamps();
        });

        // Default values
        $now = now();
        DB::table('store_settings')->insert([
            ['key' => 'store_name',               'value' => 'BioSupply UK',       'created_at' => $now, 'updated_at' => $now],
            ['key' => 'store_email',              'value' => 'hello@biosupplyuk.com', 'created_at' => $now, 'updated_at' => $now],
            ['key' => 'store_phone',              'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'store_address',            'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'currency',                 'value' => 'GBP',                'created_at' => $now, 'updated_at' => $now],
            ['key' => 'free_shipping_threshold',  'value' => '50',                 'created_at' => $now, 'updated_at' => $now],
            ['key' => 'default_tax_rate',         'value' => '20',                 'created_at' => $now, 'updated_at' => $now],
            ['key' => 'facebook_url',             'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'instagram_url',            'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'twitter_url',              'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'google_analytics_id',      'value' => '',                   'created_at' => $now, 'updated_at' => $now],
            ['key' => 'meta_title',               'value' => 'BioSupply UK — Research Peptides', 'created_at' => $now, 'updated_at' => $now],
            ['key' => 'meta_description',         'value' => 'Premium research peptides for UK researchers.', 'created_at' => $now, 'updated_at' => $now],
        ]);
    }

    public function down(): void
    {
        Schema::dropIfExists('store_settings');
    }
};
