FilamentF
Filament3y ago
dyo

closure in badgeColumn colors

I want to set the color success when the column value contains string of 'online'.

the value of column status is generated from api.

i tried below code, but i got error because of $record data is null..

BadgeColumn::make('status')
    ->formatStateUsing(fn ($record) => $this->getStatus($record->license))
    ->colors([
        'warning' => static fn ($record): bool => strpos($this->getStatus($record->license), 'logout') !== false,
        'success' => static fn ($record): bool => strpos($this->getStatus($record->license), 'online') !== false,
    ]),

what should i do?
Was this page helpful?