© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
David | Fortune Validator

Badge Color From Relationship

I have the following:

 Tables\Columns\TextColumn::make('symptomLogs.symptom.name')
                    ->badge()
                    ->color(fn (string $state): string => Symptom::where('name',$state)->first()->color)
                    ->sortable(),
 Tables\Columns\TextColumn::make('symptomLogs.symptom.name')
                    ->badge()
                    ->color(fn (string $state): string => Symptom::where('name',$state)->first()->color)
                    ->sortable(),


Context: I want the badge color to be the color set in the Symptom table.

I am outputting a list of days which will show symptoms logged via the SymptomLogs table etc. Showing the name in the badge works just fine and I can use the Eloquent Query to get the color but I feel like there may be better way to accomplish this? .
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

badge color from color field
FilamentFFilament / ❓┊help
2y ago
How to set badge color from relation
FilamentFFilament / ❓┊help
3y ago
Color For multiple badge
FilamentFFilament / ❓┊help
8mo ago