<?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('replacement_reports', function (Blueprint $table) {
            $table->id();
            $table->foreignId('id_pengguna')->nullable()->constrained('users')->nullOnDelete();
            $table->foreignId('id_barang')->constrained('inventory_items')->cascadeOnUpdate()->cascadeOnDelete();
            $table->string('jenis_laporan', 30)->default('kerusakan');
            $table->text('catatan_kerusakan');
            $table->string('lokasi_foto')->nullable();
            $table->string('status_laporan', 30)->default('diajukan');
            $table->timestamp('dibuat_pada')->nullable();
            $table->timestamp('diperbarui_pada')->nullable();
        });
    }

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