email_verified_at icon not showing when not verified
I'm attempting to display an icon indicating whether the email is verified or not in the IconColumn for the email_verified_at column. In my case, the icon is displayed when the email is verified, but it does not appear when it is not verified.
I tried:
IconColumn::make('email_verified_at')
->icon(fn (string $state): string => match ($state) {
default => 'heroicon-o-check-circle',
NULL => 'heroicon-o-x-circle',
})
Solution:Jump to solution
use it like this:
```php
Tables\Columns\IconColumn::make('email_verified_at')
->label('Verified')
->boolean()...
16 Replies
Thank you for the response but it is working for verified but not working for not verified. If you have any insights or suggestions I'd greatly appreciate it!
Ops. Sorry. I think is_verified. Your column is timestamps, right?
Why timestamps is on IconColumn?
Check your $state using
dd()
Null's are dropped in that level of state if memory serves
So how can I display an icon for the null value
->icon(fn (string $state): string => !empty($state)?'heroicon-o-check-circle':'heroicon-o-x-circle')
----------------------
you can try this, hope it will workI also tried this but it is not working.
So remove boolean as it's not boolean as nulls are dropped
Tables\Columns\IconColumn::make('email_verified_at')
->label('Verified')
->boolean()
i tried this and it works fine for me. you can try thisI have set a default icon and checked if the state is not null; if it is not null, then I set another icon. However, the default icon is still not appearing for the null state.
How can i set an icon for the null state? Could you please provide me some reference. Thank you.
add a default see:
->default(0)
if it is null, the default is applied.
This also not working. Is this a bug ?
Solution
use it like this:
Haven't tested it in V3 but it's what I use in V2 perfectly.
Thanks it's working 🥳