F
Filament8mo ago
vkDas

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', })
No description
Solution:
use it like this: ```php Tables\Columns\IconColumn::make('email_verified_at') ->label('Verified') ->boolean()...
Jump to solution
16 Replies
Shaung Bhone
Shaung Bhone8mo ago
use Filament\Tables\Columns\IconColumn;

IconColumn::make('is_featured')
->boolean()
->trueIcon('heroicon-o-check-badge')
->falseIcon('heroicon-o-x-mark')
use Filament\Tables\Columns\IconColumn;

IconColumn::make('is_featured')
->boolean()
->trueIcon('heroicon-o-check-badge')
->falseIcon('heroicon-o-x-mark')
vkDas
vkDas8mo ago
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!
Shaung Bhone
Shaung Bhone8mo ago
Ops. Sorry. I think is_verified. Your column is timestamps, right? Why timestamps is on IconColumn?
KA
KA8mo ago
Check your $state using dd()
toeknee
toeknee8mo ago
Null's are dropped in that level of state if memory serves
vkDas
vkDas8mo ago
So how can I display an icon for the null value
KA
KA8mo ago
->icon(fn (string $state): string => !empty($state)?'heroicon-o-check-circle':'heroicon-o-x-circle') ---------------------- you can try this, hope it will work
vkDas
vkDas8mo ago
I also tried this but it is not working.
toeknee
toeknee8mo ago
So remove boolean as it's not boolean as nulls are dropped
KA
KA8mo ago
Tables\Columns\IconColumn::make('email_verified_at') ->label('Verified') ->boolean() i tried this and it works fine for me. you can try this
vkDas
vkDas8mo ago
I 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.
toeknee
toeknee8mo ago
add a default see: ->default(0) if it is null, the default is applied.
vkDas
vkDas8mo ago
This also not working. Is this a bug ?
No description
Solution
toeknee
toeknee8mo ago
use it like this:
Tables\Columns\IconColumn::make('email_verified_at')
->label('Verified')
->boolean()
->trueIcon('heroicon-o-badge-check')
->falseIcon('heroicon-o-x-circle')
->default(0),
Tables\Columns\IconColumn::make('email_verified_at')
->label('Verified')
->boolean()
->trueIcon('heroicon-o-badge-check')
->falseIcon('heroicon-o-x-circle')
->default(0),
toeknee
toeknee8mo ago
Haven't tested it in V3 but it's what I use in V2 perfectly.
vkDas
vkDas8mo ago
Thanks it's working 🥳