<?php

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

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');

            $table->string('name')->index();
            $table->text('trans_name')->nullable();

            $table->string('title')->nullable()->index();
            $table->text('trans_title')->nullable();

            $table->text('copy')->nullable();
            $table->mediumText('trans_copy')->nullable();

            $table->decimal('price', 8, 2)->nullable();
            $table->decimal('price_ek', 8, 2)->nullable();
            $table->decimal('tax', 5, 2)->nullable();
            $table->decimal('price_old', 8, 2)->nullable(); //streichpreis


            $table->unsignedInteger('points')->nullable()->default(0);
            $table->unsignedInteger('weight')->nullable()->default(0);


            $table->string('contents')->nullable();
            $table->unsignedInteger('contents_total')->nullable();
            $table->unsignedTinyInteger('unit')->nullable();

            $table->string('number')->nullable();
            $table->unsignedInteger('wp_number')->nullable();

            $table->string('icons')->nullable(); //as array cast

            $table->text('description')->nullable();
            $table->mediumText('trans_description')->nullable();

            $table->text('usage')->nullable();
            $table->mediumText('trans_usage')->nullable();

            $table->text('ingredients')->nullable();
            $table->mediumText('trans_ingredients')->nullable();

            $table->tinyInteger('pos')->unsigned()->nullable();
            $table->boolean('active')->default(false);

            $table->unsignedInteger('amount')->nullable(); //for shop
            $table->string('slug')->index();


            $table->tinyInteger('show_at')->unsigned()->nullable()->default(0);
            $table->tinyInteger('amount_commission')->unsigned()->nullable()->default(0);

            $table->boolean('single_commission')->default(false);
            $table->decimal('value_commission', 5, 2)->nullable();
            $table->decimal('partner_commission', 5, 2)->nullable();


            $table->string('identifier', 20)->nullable();
            $table->string('action')->nullable();

            //is an upgrade product, set this product id by payments API paid
            $table->unsignedInteger('upgrade_to_id')->nullable();

            $table->timestamps();

            $table->softDeletes();



        });
    }

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