How can I set an Icon if file exists

How can I achieve if an image/file exists I can set an Icon in an table column and if the file/image not exist I would set an default icon. Cant seem to get the record in an IconColumn. Im usign spatie media library for filament file uploads
Solution:
Tables\Columns\IconColumn::make('image_exists')
->boolean()
->state(fn(Model $record): bool => $record->hasMedia())
Tables\Columns\IconColumn::make('image_exists')
->boolean()
->state(fn(Model $record): bool => $record->hasMedia())
...
Jump to solution
2 Replies
toeknee
toeknee3mo ago
IconColumn with formatState
Solution
LeandroFerreira
LeandroFerreira3mo ago
Tables\Columns\IconColumn::make('image_exists')
->boolean()
->state(fn(Model $record): bool => $record->hasMedia())
Tables\Columns\IconColumn::make('image_exists')
->boolean()
->state(fn(Model $record): bool => $record->hasMedia())
?