<?php

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

class CreatePaymentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payments', function (Blueprint $table) {

            $table->increments('id');
            $table->unsignedInteger('added_id')->nullable();

            $table->unsignedInteger('user_id')->nullable();
            $table->unsignedInteger('role_id')->nullable();
            $table->unsignedInteger('branch_id')->nullable();
            $table->unsignedInteger('generic_type_id')->nullable();
            $table->unsignedInteger('generic_id')->nullable();
            // THESE COLUMN INSTALLMENT_ID / COMISSION_ID DEPRECATED IN NEXT VERSION
            // $table->unsignedInteger('installment_id')->nullable();
            // $table->unsignedInteger('commission_id')->nullable();
            // $table->unsignedInteger('booking_id')->nullable();
            // END

            $table->string('receipt_no')->nullable();
            $table->enum('status', ['Unapprove', 'Approve', 'Reject', 'Reversal'])->default('Unapprove');
            $table->string('description')->nullable();
            $table->double('amount')->nullable();
            $table->string('payment_type', 25)->nullable();
            $table->string('mode', 25)->nullable();
            $table->string('drawn_on')->nullable();
            $table->string('instrument')->nullable();
            $table->timestamp('instrument_date')->nullable();
            $table->integer('post_dated')->default('0');
            $table->string('deposit_no')->nullable();
            $table->timestamp('deposit_date')->nullable();
            $table->enum('is_recycle', ['0', '1', '2'])->default('0');
            $table->enum('auto_jv', ['0', '1', '2'])->default('0');


            // FOR IMPORT DATA
            $table->string('voucher_no')->nullable();
            $table->string('narration')->nullable();
            //END

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

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