F
Filamentβ€’16mo ago
Pablo Torres

Tooltip available only if return has value.

On my table, I have this code to show a tooltip.
->tooltip(fn ($record): string => "Marked READY at: {$record->marked_ready_at}")
->tooltip(fn ($record): string => "Marked READY at: {$record->marked_ready_at}")
If the record has been marked READY the tooltip shows, eg: Marked READY at: 2023-08-01 15:34:00 But if the record has not yet been marked as READY (null), the tooltip shows: Marked READY at: I would like to have the tooltip available only when there is a date/time to show up. Is there anything to show the tooltip only when the return data is not null? Thank you.
Solution:
: ?string => $record->marked_ready_at ? 'xxx' : null ?...
Jump to solution
3 Replies
Solution
LeandroFerreira
LeandroFerreiraβ€’16mo ago
: ?string => $record->marked_ready_at ? 'xxx' : null ?
Pablo Torres
Pablo TorresOPβ€’16mo ago
Thank you @leandro_ferreira , Following your advice...
->tooltip(fn (Booking $record): ?string => $record->marked_ready_at ? "Maked READY at: {$record->marked_ready_at}" : null),
->tooltip(fn (Booking $record): ?string => $record->marked_ready_at ? "Maked READY at: {$record->marked_ready_at}" : null),
It works nicely. I hope you don't mind... I hope I'm learning the right way. The first "?" is there to check if a value type string is returned (date/time cast) The second "?" is there working with ":" checking if the value is returned, if yes I show my text and date/time otherwise empty Correct? Thank you.
LeandroFerreira
LeandroFerreiraβ€’16mo ago
the second was the question πŸ˜…
Want results from more Discord servers?
Add your server