<?php

declare(strict_types=1);

namespace App\Filament\Components\Table;

use Filament\Tables\Columns\TextColumn;

class PayablePriceTextColumn extends TextColumn
{
    public static function create(): static
    {
        return static::make('payable_price')
            ->translateLabel()
            ->sortable()
            ->numeric(
                thousandsSeparator: '،', // Using Persian thousands separator
                decimalSeparator: '/',    // Using Persian decimal separator
            )
            ->formatStateUsing(function ($state, $record) {
                // First get the formatted number with separators
                $formatted = number_format(
                    (float) $state,
                    0,
                    '/',
                    '،'
                );

                // Then convert to Persian numbers
                return str_replace(
                    ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
                    ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'],
                    $formatted
                ) . ' تومان';
            })
            ->toggleable();
    }
}
