<?php

declare(strict_types=1);

namespace App\Filament\Components\Table;

use App\Enums\Status;
use Filament\Tables\Columns\TextColumn;

class StatusTextColumn extends TextColumn
{
    public static function create($model): static
    {
        // Get available statuses for the model
        $statuses = method_exists($model, 'getValidStatuses') ? $model::getValidStatuses() : Status::get();

        // Map statuses to options (value => label)
        $colors = array_column($statuses, 'label', 'color');

        return static::make('status')
            ->label('وضعیت')
            ->toggleable()
            ->sortable()
            ->colors($colors)
            ->badge();
    }
}
