<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('obat_keluars', function (Blueprint $table) {
            $table->id();
            $table->foreignId('obat_id')->constrained('obats')->onDelete('cascade');
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
            $table->string('kode_batch');
            $table->integer('jumlah');
            $table->date('tanggal_pengeluaran');
            $table->date('tanggal_kadaluarsa');
            $table->string('no_pengeluaran')->nullable();
            $table->string('nama_petugas');
            $table->string('nama_penerima');
            $table->string('tujuan')->nullable();
            $table->text('keterangan')->nullable();
            $table->enum('status', ['terkirim', 'proses', 'dibatalkan'])->default('proses');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('obat_keluars');
    }
};
