<?php

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

class CreateInformaciaTable extends Migration
{
    const TABLE = 'informacie';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(self::TABLE, function (Blueprint $table) {
            $table->id();
            $table->foreignId('vytvoril_id')->constrained('pouzivatelia')->onDelete('cascade');
            $table->string('titulok');
            $table->text('uvod')->nullable();
            $table->text('obsah')->nullable();
            $table->string('stav');
            $table->json('zverejnit_pre_pouzivatelov_podla_role')->nullable();
            $table->dateTime('planovany_cas_zverejnenia')->nullable();
            $table->boolean('odoslat_email_na_pek')->default(false);
            $table->boolean('odoslat_email_pouzivatelom')->default(false);
            $table->boolean('odoslat_push_notifikacie_pouzivatelom')->default(false);
            $table->timestamp('cas_zverejnenia')->nullable();
            $table->boolean('odporucane')->default(false);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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