TextColumn Dynamic Color

In table we can change column color with
TextColumn::make('status')
->color('primary')
TextColumn::make('status')
->color('primary')
How can we change the color dynamically, for example if status is shipped then, it's success, if status is cancelled then it's danger.
2 Replies
einnlleinhatt_
einnlleinhatt_9mo ago
Like this ?
->color(fn (string $state): string => match ($state) {
'cancelled' => 'warning',
'shipped' => 'success',
})
->color(fn (string $state): string => match ($state) {
'cancelled' => 'warning',
'shipped' => 'success',
})
Bagus A
Bagus A9mo ago
Thanks @einnlleinhatt_