<?php

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

class CreateSaleReturnDetailsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sale_return_details', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('sale_return_id')->unsigned();
            $table->integer('sale_detail_id')->unsigned();
            $table->integer('customer_id')->unsigned();
            //$table->integer('warehouse_id')->unsigned();
            $table->integer('product_id')->unsigned();
            $table->integer('productcategory_id')->unsigned();
            //$table->integer('brand_id')->unsigned();
            $table->integer('unit_id')->unsigned();
            $table->string('code')->nullable();
            $table->string('size')->nullable();
            $table->integer('rack_no')->nullable();
            $table->integer('quantity')->unsigned();
            $table->decimal('return_price',10,2)->unsigned();
            $table->date('return_date');
            $table->foreign('sale_return_id')->references('id')->on('sale_returns')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('sale_detail_id')->references('id')->on('sale_details')->onDelete('cascade')->onUpdate('cascade');
            //$table->foreign('warehouse_id')->references('id')->on('warehouses')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('productcategory_id')->references('id')->on('productcategories')->onDelete('cascade')->onUpdate('cascade');
            //$table->foreign('brand_id')->references('id')->on('brands')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('unit_id')->references('id')->on('units')->onDelete('cascade')->onUpdate('cascade');
            $table->timestamps();
        });
    }

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