<?php

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

class CreateInvoicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('invoices', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('transaction_id')->nullable();
            $table->unsignedInteger('user_id')->nullable();
            $table->unsignedInteger('branch_id')->nullable();
            $table->unsignedInteger('role_id')->nullable();

            $table->string('invoice_no')->nullable();
            $table->string('description')->nullable();
            $table->double('amount')->nullable();
            $table->double('received_amount')->default(0);
            $table->timestamp('due_date')->nullable();
            $table->string('status')->default('Unpaid');
            $table->enum('is_recycle', ['0', '1', '2'])->default('0');

            $table->timestamps();
        }); 
    }

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