<?php

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

class CreateTransactions extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('transactions', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->unsigned();
            $table->integer('payment_id')->unsigned()->nullable();
            $table->decimal('amount',12,2);
            $table->enum('type',['payouts','appointment','realtime']);
            $table->enum('status',['paid','not paid','cancelled']);
            $table->integer('created_by')->unsigned();
            $table->timestamps();
        });
        Schema::table('transactions', function ($table) {
            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('created_by')->references('id')->on('users');

        });
    }

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