<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('buku_tamu', function (Blueprint $table) {
            $table->unsignedInteger('id_tamu')->primary();
            $table->unsignedBigInteger('id_user')->nullable();
            $table->string('nama_tamu')->nullable();
            $table->string('email')->nullable();
            $table->string('no_hp')->nullable();
            $table->string('asal_instansi')->nullable();
            $table->string('status')->nullable();
            $table->string('tanggal_kunjungan')->nullable();
            $table->string('tujuan_kunjungan')->nullable();
            $table->timestamps();

            $table->foreign('id_user')
                ->references('id')
                ->on('users')
                ->onDelete('set null');
        });
    }

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