F
Filamentβ€’4mo ago
jjo63

Filament Tables - listwithlinebreaks() - what am I doing wrong?

Hi my table column definition is like this:
Tables\Columns\TextColumn::make('filename')
->searchable()
->label('File type stats')
// ->badge()->color('info')
->getStateUsing(fn(ArchFolderV $record): string => self::getName($record))
->listWithLineBreaks(),
Tables\Columns\TextColumn::make('filename')
->searchable()
->label('File type stats')
// ->badge()->color('info')
->getStateUsing(fn(ArchFolderV $record): string => self::getName($record))
->listWithLineBreaks(),
and my getName function is this
public static function getName(ArchFolderV $record): string
{

$result = DB::table('arch_files')
->selectRaw('LOWER(SPLIT_PART(name, \'.\', -1)) AS extension, COUNT(*) AS count')
->where('arch_folder_id', '=', $record->id)
->groupBy('extension')
->orderBy('count', 'DESC')
->get();

// Convert the result into an array of strings in the format "extension: count"
$formattedResult = $result->map(function ($row) {
return "{$row->extension}: {$row->count}";
})->implode("\n");

return $formattedResult;
}
public static function getName(ArchFolderV $record): string
{

$result = DB::table('arch_files')
->selectRaw('LOWER(SPLIT_PART(name, \'.\', -1)) AS extension, COUNT(*) AS count')
->where('arch_folder_id', '=', $record->id)
->groupBy('extension')
->orderBy('count', 'DESC')
->get();

// Convert the result into an array of strings in the format "extension: count"
$formattedResult = $result->map(function ($row) {
return "{$row->extension}: {$row->count}";
})->implode("\n");

return $formattedResult;
}
My output is generated to the screen like attached image - it's the "file type stats" column I'm concerned with Anyone point to how I need to format my $formattedResult in order for this to be rendered with line breaks? thanks j
No description
Solution:
->listWithLineBreaks() is for array data
Jump to solution
3 Replies
Solution
Dennis Koch
Dennis Kochβ€’4mo ago
->listWithLineBreaks() is for array data
jjo63
jjo63OPβ€’4mo ago
Ah - ok - php knowledge failure on my part - works like a charm now πŸ™‚
Dennis Koch
Dennis Kochβ€’4mo ago
php knowledge failure on my part
Just Filament knowledge πŸ˜…
Want results from more Discord servers?
Add your server