Count chars field not working

I want to create a column that shows the length of the field title:
TextColumn::make('Title')
->formatStateUsing(function ($record) {
$length = strlen($record->title);
return "<b>{$length}</b> /" . LENGTH_TITLE;
})
->html(),
TextColumn::make('Title')
->formatStateUsing(function ($record) {
$length = strlen($record->title);
return "<b>{$length}</b> /" . LENGTH_TITLE;
})
->html(),
Solution:
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
...
Jump to solution
2 Replies
Solution
LeandroFerreira
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
lupoz
lupozOP4w ago
Thanks!
Want results from more Discord servers?
Add your server