<?php

declare(strict_types=1);

namespace App\Filament\Components\Table;

use Filament\Tables\Columns\TextColumn;

class MessageTextColumn extends TextColumn
{
    public static function create(): static
    {
        return parent::make('message')
            ->label('پیام')
            ->formatStateUsing(function ($state, $record) {
                $text = $record->message ?? '-';

                return strlen($text) > 50 ? substr($text, 0, 50) . '...' : $text;
            })
            ->sortable(['message'])
            ->toggleable();
    }
}
