<?php

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

class CreateNotisTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('notis', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('tarikh_notis')->nullable();
            $table->string('daritempoh')->nullable();
            $table->string('hinggatempoh')->nullable();
            $table->integer('sts_notis')->nullable();
            $table->integer('peringatan')->nullable();
            $table->timestamps();
        });

        Schema::create('notisperingatan', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('notis_id')->unsigned();
            $table->string('tarikh_notis');
            $table->string('kodcaw');
            $table->string('norujukan');
            $table->string('nokp');
            $table->decimal('jbg', $precision = 7, $scale = 2);
            $table->decimal('kadarupah', $precision = 5, $scale = 2)->nullable();
            $table->decimal('nilaimarhun', $precision = 9, $scale = 2);
            $table->decimal('pinjaman', $precision = 9, $scale = 2)->nullable();
            $table->decimal('bakiupah', $precision = 7, $scale = 2);
            $table->decimal('berat', $precision = 7, $scale = 2);
            $table->string('marhun');
            $table->decimal('percent', $precision = 7, $scale = 2);
            $table->integer('peringatan')->default(0);
            $table->date('tarikhnotis1')->nullable();
            $table->date('tarikhnotis2')->nullable();
            $table->timestamps();

        });


        Schema::create('cawangan_notis', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('notis_id')->unsigned();
            $table->unsignedBigInteger('kodcaw')->unsigned();
            $table->integer('peringatan')->default(0);
            $table->string('daritempoh')->nullable();
            $table->string('hinggatempoh')->nullable();
            $table->integer('status')->nullable();
            $table->timestamps();

        });
    }

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