F
Filamentβ€’13mo ago
David warner

Issue while displaying a image in column

FileUpload::make('photopath')
->disk('public')->directory('users')

->label('Photo'),


])->columns(1)->columnSpan(1),
]);

}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('email')
->searchable(),
ImageColumn::make('photopath')
->circular(),



])
FileUpload::make('photopath')
->disk('public')->directory('users')

->label('Photo'),


])->columns(1)->columnSpan(1),
]);

}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('email')
->searchable(),
ImageColumn::make('photopath')
->circular(),



])
No description
Solution:
Are you opening the site using exactly the same ? If yes did you do php artisan storage link ?
Jump to solution
12 Replies
David warner
David warnerOPβ€’13mo ago
No description
David warner
David warnerOPβ€’13mo ago
No description
Solution
einnlleinhatt_
einnlleinhatt_β€’13mo ago
Are you opening the site using exactly the same ? If yes did you do php artisan storage link ?
David warner
David warnerOPβ€’13mo ago
php artisan storage:link this did the job thank you
David warner
David warnerOPβ€’13mo ago
How do I delete/replace old image while updating ?
DrByte
DrByteβ€’13mo ago
Perhaps a (Laravel) model event observer on updating which checks isDirty() on the filename, and then deletes the old file before saving the name of the new one.
David warner
David warnerOPβ€’13mo ago
I want to remove the old image file from the storage while updating.
DrByte
DrByteβ€’13mo ago
Right. Create an observer that listens on the Model's updating event. In it, check the model's isDirty() value for the field that the file(name?) is stored to, and if it is in fact dirty (changed), then delete the old file using the name of the file currently in the record. Then when the updating event is done, Laravel will continue and finish saving the updates to the database. That's all Laravel stuff. Not related to Filament. An example: https://stackoverflow.com/a/48555062
Stack Overflow
How to incorporate ->isDirty() with laravel ->update()
I want to check if certain columns in database are changed. the update code in my controller goes like this: $tCustomer = TCustomer::withTrashed()->findOrFail($id); $tCustomer->update(requ...
DrByte
DrByteβ€’13mo ago
To do it inside Filament, I guess you could add a beforeSave() method to your Resource's Edit page and do the isDirty() check there and delete the old file there too: https://filamentphp.com/docs/3.x/panels/resources/editing-records#lifecycle-hooks
DrByte
DrByteβ€’13mo ago
Yes! That's the article I had meant to find. Forgot it was on LaravelDaily. Thanks πŸ˜„
K R A T O S
K R A T O Sβ€’11mo ago
Just a small note to this thread. If you have a specific port in which your app is running (other than default), you have to mention the port in the APP_URL (like in the ss below). Also, If using sail, Gotta do sail php artisan storage:link. One behaviour I noticed is, if you are using sail like me, If I run php artisan storage:link with out the sail, It removes or unbinds any existing storage link to/from sail and binds to local. ✌️
No description

Did you find this page helpful?