F
Filamentβ€’12mo ago
developer

ImageColumn() set path

How can I set the image path when using ImageColumn() if in the database I only have the image's name stored, not the complete path? ... btw this is an existing laravel project which I'm trying to migrate to filament πŸ¦’
Solution:
but notice you can also set the ->disk() I've created a new laravel disk with the path where my images lives, I'm using it like this: ImageColumn('user_avatar')->disk('avatars')
Jump to solution
4 Replies
johnpuddles
johnpuddlesβ€’12mo ago
You can customize the value shown in a column by using the state() method https://filamentphp.com/docs/3.x/tables/columns/getting-started#calculated-state e.g. Tables\Columns\ImageColumn::make("image") ->label("Image") ->state(function (Model $record) { return Storage::disk('cloud')->url($record->image); }),
developer
developerβ€’12mo ago
nice to know
Solution
developer
developerβ€’12mo ago
but notice you can also set the ->disk() I've created a new laravel disk with the path where my images lives, I'm using it like this: ImageColumn('user_avatar')->disk('avatars')
Sandeep
Sandeepβ€’11mo ago
Thank you, it's work for me
Want results from more Discord servers?
Add your server
More Posts