<?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('settings', function (Blueprint $table) {
            $table->string('key')->primary();
            $table->text('value')->nullable();
            $table->timestamps();
        });

        // Default values
        DB::table('settings')->insert([
            ['key' => 'project_name',         'value' => 'On Cloud API',                  'created_at' => now(), 'updated_at' => now()],
            ['key' => 'site_url',             'value' => 'http://localhost:8000',          'created_at' => now(), 'updated_at' => now()],
            ['key' => 'subdomains',           'value' => 'www,apps',                       'created_at' => now(), 'updated_at' => now()],
            ['key' => 'app_debugging',        'value' => '0',                              'created_at' => now(), 'updated_at' => now()],
            ['key' => 'disable_landing_page', 'value' => '0',                              'created_at' => now(), 'updated_at' => now()],
            ['key' => 'wildcard_domain',      'value' => '0',                              'created_at' => now(), 'updated_at' => now()],
            ['key' => 'pagination_count',     'value' => '100',                            'created_at' => now(), 'updated_at' => now()],
            ['key' => 'file_storage',         'value' => 'local',                          'created_at' => now(), 'updated_at' => now()],
            ['key' => 'aws_access_key',       'value' => '',                               'created_at' => now(), 'updated_at' => now()],
            ['key' => 'aws_secret_key',       'value' => '',                               'created_at' => now(), 'updated_at' => now()],
            ['key' => 'aws_region',           'value' => '',                               'created_at' => now(), 'updated_at' => now()],
            ['key' => 'aws_bucket',           'value' => '',                               'created_at' => now(), 'updated_at' => now()],
            ['key' => 'aws_bucket_url',       'value' => '',                               'created_at' => now(), 'updated_at' => now()],
            ['key' => 'default_language',     'value' => 'EN',                             'created_at' => now(), 'updated_at' => now()],
            ['key' => 'available_languages',  'value' => 'EN,English,FR,French',           'created_at' => now(), 'updated_at' => now()],
            ['key' => 'timezone',             'value' => 'Asia/Karachi',                   'created_at' => now(), 'updated_at' => now()],
            ['key' => 'default_currency',     'value' => 'USD',                            'created_at' => now(), 'updated_at' => now()],
            ['key' => 'money_conversion',     'value' => '1',                              'created_at' => now(), 'updated_at' => now()],
            ['key' => 'time_format',          'value' => 'AM/PM',                          'created_at' => now(), 'updated_at' => now()],
            ['key' => 'date_format',          'value' => 'd M Y h:i A',                    'created_at' => now(), 'updated_at' => now()],
            ['key' => 'working_time_format',  'value' => 'E HH:mm',                        'created_at' => now(), 'updated_at' => now()],
            ['key' => 'phone_country_code',   'value' => 'US',                             'created_at' => now(), 'updated_at' => now()],
            ['key' => 'pusher_app_id',        'value' => '1822918',                        'created_at' => now(), 'updated_at' => now()],
            ['key' => 'pusher_app_key',       'value' => '178065a5c333471605f3',           'created_at' => now(), 'updated_at' => now()],
            ['key' => 'pusher_app_secret',    'value' => '5a012b3ca2d5a73e1187',           'created_at' => now(), 'updated_at' => now()],
            ['key' => 'pusher_app_cluster',   'value' => 'mt1',                            'created_at' => now(), 'updated_at' => now()],
            ['key' => 'broadcast_driver',     'value' => 'pusher',                         'created_at' => now(), 'updated_at' => now()],
        ]);
    }

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