<?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('company_assets', function (Blueprint $table) {
            $table->id();
            $table->foreignId('company_id')->constrained('companies')->onDelete('cascade');
            $table->string('asset_number')->nullable();
            $table->string('name');
            $table->text('description')->nullable();
            $table->enum('category', ['real_estate', 'equipment', 'vehicle', 'furniture', 'technology', 'inventory', 'investment', 'intangible', 'other'])->default('other');
            $table->decimal('purchase_value', 15, 2)->default(0);
            $table->decimal('current_value', 15, 2)->default(0);
            $table->date('purchase_date')->nullable();
            $table->string('vendor_name')->nullable();
            $table->string('location')->nullable();
            $table->enum('status', ['active', 'sold', 'disposed', 'maintenance', 'retired'])->default('active');
            $table->date('warranty_expiry')->nullable();
            $table->text('notes')->nullable();
            $table->string('receipt_path')->nullable();
            $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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