<?php

declare(strict_types=1);

use Hypervel\Database\Migrations\Migration;
use Hypervel\Support\Str;

class AddBibleVerseSystemSettings extends Migration
{
    public function up(): void
    {
        if (!\DB::table('system_settings')->where('key', 'bible_verse_text')->exists()) {
            \DB::table('system_settings')->insert([
                'hashkey'     => (string) Str::uuid() . Str::random(100),
                'key'         => 'bible_verse_text',
                'value'       => '',
                'type'        => 'textarea',
                'group'       => 'content',
                'label'       => 'Bible Verse of the Day',
                'description' => 'The verse text displayed on the homepage for all users. Leave empty to hide.',
                'created_at'  => now(),
                'updated_at'  => now(),
            ]);
        }

        if (!\DB::table('system_settings')->where('key', 'bible_verse_reference')->exists()) {
            \DB::table('system_settings')->insert([
                'hashkey'     => (string) Str::uuid() . Str::random(100),
                'key'         => 'bible_verse_reference',
                'value'       => '',
                'type'        => 'text',
                'group'       => 'content',
                'label'       => 'Bible Verse Reference',
                'description' => 'The book, chapter, and verse (e.g. "John 3:16 NIV").',
                'created_at'  => now(),
                'updated_at'  => now(),
            ]);
        }
    }

    public function down(): void
    {
        \DB::table('system_settings')->whereIn('key', ['bible_verse_text', 'bible_verse_reference'])->delete();
    }
}
