<?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('transactions', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->double('amount');
            $table->double('amount_received')->nullable();
            $table->enum('type',['Payment','Payout','Muhandisin Profit']);
            $table->foreignId('milestone_id')->nullable();
            $table->foreignId('from')->nullable()->references('id')->on('wallets')->cascadeOnUpdate()->nullOnDelete();
            $table->timestamp('confirmed_at')->nullable();
            $table->foreignId('confirmed_by')->nullable()->references('id')->on('users');
            $table->string('status');
            $table->foreignId('to')->nullable()->references('id')->on('wallets')->cascadeOnUpdate()->nullOnDelete();
            $table->string('stripe_id')->nullable();
            $table->string('stripe_type')->nullable();
            $table->json('stripe_data')->nullable();
            $table->softDeletes();
        });
    }

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