<?php

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

class CreatePromotionAdminProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('promotion_admin_products', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('promotion_admin_id')->index();
            $table->unsignedInteger('product_id')->index();

            $table->boolean('own_price')->default(false);
            $table->decimal('price', 8, 2)->nullable();
            $table->decimal('tax', 5, 2)->nullable();
            $table->decimal('price_old', 8, 2)->nullable(); //streichpreis

            $table->boolean('calcu_commission')->default(true);

            $table->unsignedSmallInteger('max_items')->nullable();
            $table->unsignedSmallInteger('used_items')->nullable();
           
            $table->boolean('shipping')->default(true);

            $table->boolean('active')->default(false);

            $table->foreign('promotion_admin_id')
                ->references('id')
                ->on('promotion_admins');     

            $table->foreign('product_id')
                ->references('id')
                ->on('products');

               
            $table->timestamps();
        });
    }

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