NDO
ImageColumn default url for stacked columns
Hey 👋 I am trying to create a stacked image column for related model (users). Because user model image is not required I want to set default image url with method that returns full url of user avatar if his img_path field is empty.
I tried with code below but it is not working because the method defaultImageUrl should return the string and not the array value. Does anyone know how I can set default image url for the stacked ImageColumn?
Tables\Columns\ImageColumn::make('users.img_path')
->label('Peoples')
->circular()
->stacked()
->limit()
->limitedRemainingText()
->defaultImageUrl(function ($record) {
$images=[];
foreach($record->users as $user) {
$images[] = $user->getImageUrl();
}
return $images;
}),
14 replies