<?php

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

class CreateShopPaymentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_payments', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->unsignedBigInteger('bill_generate_id')->nullable();
            $table->unsignedBigInteger('shop_bill_id')->nullable();
            $table->unsignedBigInteger('shop_id')->nullable();
            $table->double('paid_amount', 8,2)->nullable();
            $table->text('payment_note')->nullable();
            $table->string('payment_method')->nullable();
            $table->string('paid_by')->nullable();
            $table->string('paid_month')->nullable();
            $table->string('paid_year')->nullable();
            $table->string('paid_date')->nullable();
            $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_bill_id')->references('id')->on('shop_bills')->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_payments');
    }
}
