<?php

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

class CreatePageBlocksLang extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('blocks_lang', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('block_id');
            $table->string('language_id', 10);
            $table->string('title', 150);

            // Block available fields
            $table->string('block_title', 300)->nullable();
            $table->string('block_subtitle', 300)->nullable();
            $table->text('content')->nullable();
            $table->text('cta1')->nullable();


            // Languages
            $table->unique(['block_id', 'language_id'], 'idx_block_lang');
            $table->foreign('block_id')
                ->references('id')
                ->on('blocks')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');

        });
    }

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