Using `icons` with IconColumn
Hi,
I'm just playing with the Table Builder and using the User model for example.
I was looking at using the
IconColumn
on the email_verified_at
column, to show if it is verified or not. I think this class is better suited to a boolean field, but just trying it out.
I saw the options
method was deprecated (though no mention of that in the docs) and saw it recommended to use icons
instead.
I tried:
But I get no icons.
I also tried with the icon
method and a ternary operator
This gets me a bit further and shows the ✅ but not the ❌
Perhaps I'm missing something?
Thanks.5 Replies
Maybe ->icon(fn($state) => $state ? ‘heroicon-o-x-mark’ : ‘heroicon-o-check-circle’)
Switch the icons. Sorry.
No, I still don't get an image for the false value.
Can you dd the $state to see what it’s outputting?
It may not be coming back as null for some reason.
Not works with me also:
Tables\Columns\IconColumn::make('email_verified_at')
->label('Email Verified')
->icon(fn($state) => $state ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
->sortable(),
Have you resolved it ?