<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('receipts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('record_id')->nullable();
            $table->foreign('record_id')->nullable()->references('id')->on('records')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('member_id')->nullable();
            $table->foreign('member_id')->nullable()->references('id')->on('members')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('supplier_id')->nullable();
            $table->foreign('supplier_id')->nullable()->references('id')->on('suppliers')->onUpdate('cascade')->onDelete('cascade');
            //$table->unsignedBigInteger('causal_id');
            //$table->foreign('causal_id')->nullable()->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
            $table->unsignedBigInteger('payment_method_id');
            $table->foreign('payment_method_id')->nullable()->references('id')->on('payment_methods')->onUpdate('cascade')->onDelete('cascade');
            $table->integer('number');
            $table->datetime('date');
            //$table->integer('month');
            $table->integer('year');
            $table->enum('type', ['IN', 'OUT']);
            //$table->decimal('amount', $precision = 8, $scale = 2);
            //$table->integer('commercial')->default(1);
            $table->integer('status');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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