<?php

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

/**
 * Class CreateTerminyUdalostRegistracieTable
 */
return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('terminy_udalost_registracie', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('udalost_id');
            $table->unsignedBigInteger('pouzivatel_id')->nullable();
            $table->unsignedBigInteger('vytvoril_id');
            $table->unsignedBigInteger('pracovisko_id');

            $table->string('meno')->nullable();
            $table->string('priezvisko')->nullable();
            $table->longText('poznamka')->nullable();

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

            $table->foreign('udalost_id')->references('id')->on('terminy_udalost_udalosti')->onDelete('cascade');
        });
    }

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