<?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('metodo_pagamento', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('attivita_id')->unsigned()->nullable();
            $table->string('nome');
            $table->string('descrizione')->nullable();
            $table->boolean('is_attivo')->default(true);
            $table->boolean('is_pubblico')->default(false);
            $table->string('key')->nullable();
            $table->string('secret')->nullable();
            $table->string('tipo')->nullable();
            $table->string('path_img')->nullable();
            $table->json('info')->nullable();
            $table->timestamps();
        });

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

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