formatStateUsing not called if value is null

                Tables\Columns\TextColumn::make('cancelled_at')
                    ->label('Cancelled')
                    ->formatStateUsing(fn (?string $state) => $state ? 'Yes' : 'No')
                    ->colors([
                        'success' => static fn (?string $state): bool => empty($state),
                        'danger' => static fn (?string $state): bool => !empty($state),
                    ]),


This does echo "Yes" but if cancelled_at is
null
it wont show "No".
Solution
Use getStateUsing() instead
Was this page helpful?