<?php

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

class CreateWorkerRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('worker_records', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('worker_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->date('transaction_date');
            $table->decimal('total_price',10,2)->nullable();
            $table->decimal('payment_amount',10,2)->nullable();
            $table->decimal('due_amount',10,2)->nullable();
            $table->decimal('previous_due',10,2)->nullable();
            $table->decimal('total_due',10,2)->nullable();
            $table->string('message',600)->nullable();
            $table->string('note',600)->nullable();
            $table->string('status')->default('Pending');//Sent
            $table->dateTime('send_at')->nullable();
            $table->integer('send_by')->unsigned()->nullable();
            $table->integer('created_by')->unsigned()->nullable();
            $table->integer('updated_by')->unsigned()->nullable();
            $table->foreign('worker_id')->references('id')->on('workers')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
            $table->timestamps();
        });
    }

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