<?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('evento', function (Blueprint $table) {
            $table->id();
            $table->string('nome')->nullable();
            $table->string('descrizione')->nullable();
            $table->date('data_inizio')->nullable();
            $table->date('data_fine')->nullable();
            $table->date('apertura_prenotazione')->nullable();
            $table->date('chiusura_prenotazione')->nullable();
            $table->boolean('prezzo_fisso')->default(false);
            $table->decimal('prezzo', 10, 2)->nullable();
            $table->string('stato')->default('attivo')->nullable();
            $table->string('note')->nullable();
            $table->boolean('is_attivo')->default(true);
            $table->string('codice')->unique();
            $table->string('immagine')->nullable();
            $table->json('info')->nullable();
            $table->timestamps();
        });
        
        Schema::table('prenotazione', function (Blueprint $table) {
            $table->foreign('evento_id')->references('id')->on('evento')->onDelete('cascade');
        });
 
    }

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