<?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->timestamps();
			$table->softDeletes();
			$table->integer('company_id')->unsigned();
			$table->foreign('company_id')->references('id')->on('companies');
			$table->integer('customer_id')->unsigned();
			$table->foreign('customer_id')->references('id')->on('customers');
			$table->integer('property_id')->unsigned();
			$table->foreign('property_id')->references('id')->on('properties');
			$table->integer('work_order_id')->nullable();
			$table->string('number')->nullable();
			$table->date('date');
			$table->date('date_due')->nullable();
			$table->date('date_paid')->nullable();
			$table->longText('description')->nullable();
			$table->text('about')->nullable();
			$table->decimal('amount', 10, 2);
			$table->decimal('discount', 10, 2)->nullable();
			$table->integer('status')->default(0);
			$table->string('send_by')->nullable();
			$table->integer('quickbooks_id')->nullable();
			$table->string('hash')->unique()->nullable();
        });
    }

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