<?php

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

/**
 * Class CreateVzdelavanieKniznicaUcebniceTable
 */
return new class extends Migration
{
    /**
     * @return void
     */
    public function up()
    {
        Schema::create('vzdelavanie_kniznica_ucebnice', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('kategoria_id');

            $table->string('nazov')->default('Názov učebnice');
            $table->string('autor')->nullable();
            $table->text('popis')->nullable();
            $table->string('obrazok')->nullable();
            $table->boolean('verejne')->default(false);

            $table->timestamps();

            $table->foreign('kategoria_id')->references('id')->on('vzdelavanie_kniznica_kategorie')->onDelete('cascade');
        });
    }

    /**
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vzdelavanie_kniznica_ucebnice');
    }
};
