<?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('service_tickets', function (Blueprint $table) {
            $table->id();
            $table->string('ticket_code', 20)->unique();
            $table->foreignId('customer_id')->constrained('customers')->cascadeOnDelete();
            $table->enum('device_type', ['Laptop', 'PC', 'Printer']);
            $table->string('brand');
            $table->string('model');
            $table->string('serial_number')->nullable();
            $table->text('problem_desc');
            $table->enum('status', ['Pending', 'Repairing', 'Ready', 'Picked Up', 'Cancelled'])
                  ->default('Pending');
            $table->text('cancel_reason')->nullable();
            $table->timestamp('picked_up_at')->nullable();
            $table->timestamp('cancelled_at')->nullable();
            $table->timestamps();
        });
    }

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