<?php

use App\Enums\SupportTicketPriorityEnum;
use App\Enums\SupportTicketStatusEnum;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('support_tickets', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(\App\Models\User::class)->constrained()->cascadeOnDelete();
            $table->string('ticket_no')->unique();
            $table->string('subject');
            $table->longText('message');
            $table->longText('attachments')->nullable();
            $table->enum('status', allowed: SupportTicketStatusEnum::values())->default(SupportTicketStatusEnum::OPEN->value);
            $table->enum('priority', SupportTicketPriorityEnum::values())->default(SupportTicketPriorityEnum::LOW->value);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('support_tickets');
    }
};
