<?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_tag')->unique();
            $table->enum('device_type', ['Laptop', 'Desktop', 'Phone']);
            $table->string('brand')->nullable();
            $table->string('model')->nullable();
            $table->string('serial_number')->nullable();
            $table->enum('condition', ['New', 'Old', 'Refurbished'])->default('New');
            $table->date('purchase_date')->nullable();
            $table->date('warranty_expiry')->nullable();
            $table->string('microsoft_account')->nullable();
            $table->string('ram')->nullable();
            $table->string('storage')->nullable();
            $table->enum('status', ['In-Stock', 'Assigned', 'Repair', 'Scrap'])->default('In-Stock');
            $table->decimal('cost', 12, 2)->nullable();
            $table->text('remarks')->nullable();
            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();
        });
    }

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