<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('app_configurations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->nullable();

            $table->string('app_name')->nullable();
            $table->string('author_name')->nullable();
            $table->string('footer_copyright')->nullable();
            $table->string('app_email')->nullable();
            $table->string('app_phone')->nullable();
            $table->text('app_short_description')->nullable();
            $table->string('white_logo')->nullable();
            $table->string('small_white_logo')->nullable();
            $table->string('favicon')->nullable();
            $table->string('background_image')->nullable();
            $table->string('preloader_image')->nullable();

            $table->tinyInteger('email_configuration_status')->default(EMAIL_CONFIGURATION_STATUS_DISABLE);
            $table->string('mailer')->nullable();
            $table->string('port')->nullable();
            $table->string('host')->nullable();
            $table->string('username')->nullable();
            $table->string('password')->nullable();
            $table->string('encryption')->nullable();
            $table->string('mail_from_name')->nullable();
            $table->string('mail_from_address')->nullable();

            $table->tinyInteger('google_login_status')->default(GOOGLE_LOGIN_STATUS_DISABLE);
            $table->string('google_client_id')->nullable();
            $table->string('google_secret_id')->nullable();
            $table->string('google_redirect_url')->nullable();
            $table->tinyInteger('facebook_login_status')->default(FACEBOOK_LOGIN_STATUS_DISABLE);
            $table->string('facebook_client_id')->nullable();
            $table->string('facebook_secret_id')->nullable();
            $table->string('facebook_redirect_url')->nullable();
            $table->tinyInteger('recaptcha_status')->default(FACEBOOK_LOGIN_STATUS_DISABLE);
            $table->string('recaptcha_site_key')->nullable();
            $table->string('recaptcha_secret_key')->nullable();

            $table->tinyInteger('preloader_status')->default(PRELOADER_STATUS_ENABLE);
            $table->tinyInteger('language_status')->default(LANGUAGE_STATUS_ENABLE);
            $table->tinyInteger('frontend_status')->default(LANGUAGE_STATUS_ENABLE);

            foreach (socialAccounts() as $key => $value) {
                $table->string($key)->nullable();
            }
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('app_configurations');
    }
};
