<?php

use App\Models\Setting;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        $settings = [
            [
                'key' => 'require_auth_for_adoption_applications',
                'value' => '1',
                'type' => 'boolean',
                'group' => 'application',
                'description' => 'Require authentication to submit adoption applications',
            ],
            [
                'key' => 'require_auth_for_fostering_applications',
                'value' => '1',
                'type' => 'boolean',
                'group' => 'application',
                'description' => 'Require authentication to submit fostering applications',
            ],
            [
                'key' => 'require_auth_for_assistance_applications',
                'value' => '1',
                'type' => 'boolean',
                'group' => 'application',
                'description' => 'Require authentication to submit assistance applications',
            ],
        ];

        foreach ($settings as $setting) {
            Setting::updateOrCreate(
                ['key' => $setting['key']],
                $setting
            );
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Setting::whereIn('key', [
            'require_auth_for_adoption_applications',
            'require_auth_for_fostering_applications',
            'require_auth_for_assistance_applications',
        ])->delete();
    }
};
