© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
_wbit

BadgeColumn -> condition using values from two columns

I'm trying to use BadgeColumn on a table with 'stock' and 'stock_alert' columns and my intention is to paint the 'stock' with a color based on the relationship to the 'stock_alert', my code is as follows:
BadgeColumn::make('stock')
                      ->label('Stocks')
                      ->colors([
                          'success',
                          'danger' => static fn ($stock): bool => $stock === 0,
                          'primary' => static fn ($stock) => $stock <= DB::select('stock_alert'),
                      ]),
BadgeColumn::make('stock')
                      ->label('Stocks')
                      ->colors([
                          'success',
                          'danger' => static fn ($stock): bool => $stock === 0,
                          'primary' => static fn ($stock) => $stock <= DB::select('stock_alert'),
                      ]),

The 'danger' color applies fine when $stock is 0.
But the problem is in comparing $stock with 'stock_alert', I can't get that value.
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

Two columns form
FilamentFFilament / ❓┊help
3y ago
two columns from a single database column
FilamentFFilament / ❓┊help
2y ago
Two columns in one cell
FilamentFFilament / ❓┊help
3y ago
Merge two columns into one?
FilamentFFilament / ❓┊help
3y ago