<?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('assets', function (Blueprint $table) {
            $table->id();
            $table->string('asset_id')->unique();
            $table->string('name');
            $table->text('description')->nullable();
            $table->string('category')->nullable();
            $table->string('serial_number')->unique();
            $table->string('photo')->nullable();
            $table->date('purchase_date');
            $table->date('warranty_expiry')->nullable();
            $table->decimal('purchase_price', 10, 2)->nullable();
            $table->string('vendor')->nullable();
            $table->enum('status', ['Available', 'Assigned', 'Maintenance', 'Retired'])->default('Available');
            $table->foreignId('assigned_to')->nullable()->constrained('employees')->onDelete('set null');
            $table->date('assigned_date')->nullable();
            $table->text('notes')->nullable();
            $table->timestamps();
        });
    }

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