You need to save model changes.
$user->profile_image = "";
$user->save();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I make a livewire compnent who store, update profile photo well. But the issue is with delete method displayed below. When I click on Delete Button nothing happen. Is this code correct because the update method delete old image and replace it with a new one well.
/**
* Update profile image
*/
public function updateProfileImage(): void
{
$this->validate([
'newProfileImage' => 'image|mimes:png,jpg,jpeg,gif,svg|extensions:png,jpg,jpeg,gif,svg|max:2048'
]);
$user = User::find(Auth::id());
$name = $user->profile_image;
if ($this->newProfileImage) {
Storage::delete('public/profile_images/' . $user->profile_image);
$name = md5($this->newProfileImage . microtime()) . '.' . $this->newProfileImage->extension();
$this->newProfileImage->storeAs('profile_images', $name, 'public');
} else {
$name = $user->profile_image;
}
$user->profile_image = $name;
$user->update();
$this->dispatch('refresh-me');
$this->newProfileImage = null;
}
/**
* Delete profile image
*/
public function deleteProfileImage(): void
{
$user = User::find(Auth::id());
Storage::delete('public/profile_images/' . $user->profile_image);
$user->profile_image = "";
$this->dispatch('refresh-me');
}
I found the solution. Because I use Breeze Starter Kit with Volt Class, I migrate my Livewire method deleteProfileImage from the component ProfileImage to its own Volt Class and everything works fine. I do not know if there's somewhere any conflict between Breeze Volt Components handling profile feature and my Livewire classic component method but it works fine.
Please or to participate in this conversation.