<?php

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

class CreateShopBillsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_bills', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->unsignedBigInteger('bill_generate_id')->nullable();
            $table->unsignedBigInteger('shop_id')->nullable();
            $table->double('shop_size', 8,2)->nullable();
            $table->double('shop_service_charge', 8,2)->nullable();
            $table->double('net_amount', 8,2)->nullable();
            $table->double('paid_amount', 8,2)->nullable();
            $table->double('due_amount', 8,2)->nullable();
            $table->double('change_amount', 8,2)->nullable();
            $table->boolean('is_pay')->default(false);
            $table->boolean('status')->default(true);
            $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('bill_generate_id')->references('id')->on('bill_generates')->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('shop_id')->references('id')->on('shops')->onUpdate('cascade')->onDelete('cascade');
            $table->timestamps();
        });
    }

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