F
Filament5mo ago
Sven

stacked Imagecolumn with tooltip/title?

Hey! I'm doing exactly the use case from the doc: https://filamentphp.com/docs/3.x/tables/columns/image#stacking-images stacking images representing the user avatars. I saw that one can add extra-attributes like this
->extraImgAttributes(fn (Company $record): array => [
'alt' => "{$record->name} logo",
]),
->extraImgAttributes(fn (Company $record): array => [
'alt' => "{$record->name} logo",
]),
But in that case $record refers to the record of the row, not the iterated record (i.e in my case, the todo which has a relation to all assigned uses, instead of the current user whos avatar is being rendered). But not everybody knows everybody from their looks / even has an avatar. Is there a way to have a tooltip or even title-attribute when hovering the avatars?
1 Reply
Sven
SvenOP5mo ago
In the meantime I tried doing something like this but $state is all of the stacked images and I don't know my current index:
Tables\Columns\ImageColumn::make('assignments.user.profile_photo_url')
->circular()
->stacked()
->tooltip(
fn(Order $record, $state) => $record->assignments->filter(
fn($assignment) => $assignment->user->profile_photo_url === $state[0]
)->first()->user->name)
->label('#'),
Tables\Columns\ImageColumn::make('assignments.user.profile_photo_url')
->circular()
->stacked()
->tooltip(
fn(Order $record, $state) => $record->assignments->filter(
fn($assignment) => $assignment->user->profile_photo_url === $state[0]
)->first()->user->name)
->label('#'),

Did you find this page helpful?