F
Filament6mo ago
Pscl

Showing icons in Table Column Badge

Hey all,
Tables\Columns\TextColumn::make('types.name')->badge()->icon('types.icon')
Tables\Columns\TextColumn::make('types.name')->badge()->icon('types.icon')
Iam trying to accomplish this. As my types are stored in database and not as enum, how can I add icon within the badge that loads the icon from icon column in types table? Thanks!
7 Replies
Pscl
PsclOP6mo ago
Yes, but state does not have the relation item. It has the full relation.
umardi_
umardi_6mo ago
how about use $record instead? not $state, get relationship manually, something like $record->types
LeandroFerreira
LeandroFerreira6mo ago
->icons(fn(YourModel $record) => $record->types->pluck('name', 'icon'))
->icons(fn(YourModel $record) => $record->types->pluck('name', 'icon'))
?
Pscl
PsclOP6mo ago
@Leandro Ferreira thanks. Did you test it? Somehow for me icons are not showing up.
LeandroFerreira
LeandroFerreira6mo ago
are you using heroicons?
Pscl
PsclOP6mo ago
worked! I had an issue. Thanks!
Want results from more Discord servers?
Add your server