<?php

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

class CreateVpPortalSettingsTable extends Migration
{
    public function up()
    {
        if (Schema::hasTable('vp_portal_settings')) return;

        Schema::create('vp_portal_settings', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id')->unique();
            $table->boolean('enabled')->default(false);
            $table->string('clinic_name', 150)->nullable();
            $table->string('logo_path', 255)->nullable();
            $table->string('primary_color', 20)->default('#2563eb');
            $table->text('welcome_text')->nullable();
            $table->string('whatsapp_number', 30)->nullable();
            // portal_slug → per-clinic URL segment (/portal/{slug}); custom_domain
            // is stored for a future subdomain/vhost setup.
            $table->string('portal_slug', 80)->nullable()->unique();
            $table->string('custom_domain', 150)->nullable();
            $table->timestamps();
        });
    }

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