<?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
    {
        if (! Schema::hasTable('business_expenses')) {
            Schema::create('business_expenses', function (Blueprint $table) {
                $table->id();
                $table->date('expense_date')->index();
                $table->string('category', 60)->index();
                $table->decimal('amount', 24, 8);
                $table->string('reference')->nullable();
                $table->text('note')->nullable();
                $table->foreignId('created_by_admin_id')->nullable()->constrained('admins')->nullOnDelete();
                $table->timestamps();
            });
        }
    }

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