<?php

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

/**
 * Promotional ad banners shown in the customer app. Each banner sits in a
 * "placement" (an ad space/slot) and the admin toggles it active/inactive.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('banners', function (Blueprint $table) {
            $table->id();
            $table->string('title');                         // admin reference + image alt
            $table->string('placement')->default('home_top'); // ad space slot
            $table->string('image');                          // public-disk path
            $table->string('link_type')->default('none');     // none|url|category|product|vendor
            $table->string('link_value')->nullable();         // URL, or slug for in-app targets
            $table->boolean('is_active')->default(true);
            $table->unsignedInteger('sort_order')->default(0);
            $table->timestamp('starts_at')->nullable();       // optional schedule
            $table->timestamp('ends_at')->nullable();
            $table->timestamps();

            $table->index(['placement', 'is_active']);
        });
    }

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