<?php

namespace App\Enums;

enum AttendanceStatusEnum: int
{
    case PRESENT = 1;
    case ABSENT  = 2;
    case PENDING = 3;

    public static function labels(): array
    {
        return [
            self::PRESENT->value => __('Present'),
            self::ABSENT->value  => __('Absent'),
            self::PENDING->value => __('Pending'),
        ];
    }

    public static function colors(): array
    {
        return [
            self::PRESENT->value => 'success',
            self::ABSENT->value  => 'danger',
            self::PENDING->value => 'warning',
        ];
    }

    public static function label(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::labels()[$key] ?? '';
    }

    public static function color(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::colors()[$key] ?? 'secondary';
    }

    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    public static function badge(self|int|null $value): string
    {
        $color = self::color($value);
        $label = self::label($value);
        return '<span class="badge bg-' . $color . '">' . $label . '</span>';
    }
}
