drewneon
drewneon
FFilament
Created by drewneon on 1/13/2024 in #❓┊help
Delete avatar image file from local storage
I managed to eliminate the error message by changing the if condition from $user->isDirty('avatar_url') to is_null($user->avatar_url). Is it good enough?
11 replies
FFilament
Created by drewneon on 1/13/2024 in #❓┊help
Delete avatar image file from local storage
Thanks a lot! I've tried Method 1, the avatar file was successfully deleted when I clicked the "x" button and then the Update button. However, when I tried to set a new avatar, it threw the following error when hitting the Update button. League\Flysystem\Filesystem::delete(): Argument #1 ($location) must be of type string, null given, called in /var/www/filament/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php on line 513 This error points to the line within the isDirty condition.
11 replies
FFilament
Created by drewneon on 1/13/2024 in #❓┊help
Delete avatar image file from local storage
Thanks again! From the steps to enable user avatars I learned from the web page mentioned previously, I don't see where the url of the old avatar is stored, i.e. the new avatar url is stored and replaces the old one in the db immediately after hitting the Update button, including avatar deletion. If removing the avatar image file from disk is not doable simutanesouly, the only way I could think of is comparing all the avatar files with all the user's avatar urls in the db and deleting unmatched ones then, which is quite resource comsuming, especially when there are thousands of avatar image files as the web site grows.
11 replies
FFilament
Created by drewneon on 1/13/2024 in #❓┊help
Delete avatar image file from local storage
Thanks for your response! The avatar url is saved to the db when clicking the Update button in the user profile page, no matter adding or removing the user avatar. Is it more logical to remove the old avatar file simultaneously?
11 replies