F
Filament7mo 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
PsclOP7mo ago
Yes, but state does not have the relation item. It has the full relation.
umardi_
umardi_7mo ago
how about use $record instead? not $state, get relationship manually, something like $record->types
LeandroFerreira
LeandroFerreira7mo ago
->icons(fn(YourModel $record) => $record->types->pluck('name', 'icon'))
->icons(fn(YourModel $record) => $record->types->pluck('name', 'icon'))
?
Pscl
PsclOP7mo ago
@Leandro Ferreira thanks. Did you test it? Somehow for me icons are not showing up.
LeandroFerreira
LeandroFerreira7mo ago
are you using heroicons?
Pscl
PsclOP7mo ago
worked! I had an issue. Thanks!
Want results from more Discord servers?
Add your server