<?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('ordine', function (Blueprint $table) {
            $table->id();
            $table->string('riferimento')->nullable();
            $table->bigInteger('prenotazione_id')->unsigned()->nullable();
            $table->string('stato');
            $table->bigInteger('dispositivo_id')->unsigned()->nullable();
            $table->bigInteger('pagamento_id')->unsigned()->nullable();
            $table->bigInteger('attivita_id')->unsigned()->nullable();
            $table->string('note')->nullable();
            $table->string('codice')->unique()->nullable();
            $table->string('tipo')->nullable();
            $table->decimal('prezzo', 10, 2)->nullable();
            $table->bigInteger('metodo_pagamento_id')->unsigned()->nullable();
            $table->json('info')->nullable();
            $table->timestamps();
        });

        Schema::table('ordine', function (Blueprint $table) {
            $table->foreign('prenotazione_id')->references('id')->on('prenotazione')->onDelete('cascade');
            // $table->foreign('attivita_id')->references('id')->on('attivita')->onDelete('cascade');
            // $table->foreign('metodo_pagamento_id')->references('id')->on('metodo_pagamento')->onDelete('cascade');
        });
    }

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