diff --git a/routes/inertia.php b/routes/inertia.php
index 243eb5ae1..e9c417235 100644
--- a/routes/inertia.php
+++ b/routes/inertia.php
@@ -22,6 +22,9 @@
Route::delete('/user', [CurrentUserController::class, 'destroy'])
->name('current-user.destroy');
+ Route::delete('/user/profile-photo', [CurrentUserController::class, 'deleteProfilePhoto'])
+ ->name('current-user-photo.destroy');
+
// API...
if (Jetstream::hasApiFeatures()) {
Route::get('/user/api-tokens', [ApiTokenController::class, 'index'])->name('api-tokens.index');
diff --git a/src/HasProfilePhoto.php b/src/HasProfilePhoto.php
index 1cb4ef987..82382695f 100644
--- a/src/HasProfilePhoto.php
+++ b/src/HasProfilePhoto.php
@@ -28,6 +28,20 @@ public function updateProfilePhoto(UploadedFile $photo)
});
}
+ /**
+ * Delete the user's profile photo.
+ *
+ * @return void
+ */
+ public function deleteProfilePhoto()
+ {
+ Storage::disk($this->profilePhotoDisk())->delete($this->profile_photo_path);
+
+ $this->forceFill([
+ 'profile_photo_path' => null,
+ ])->save();
+ }
+
/**
* Get the URL to the user's profile photo.
*
diff --git a/src/Http/Controllers/Inertia/CurrentUserController.php b/src/Http/Controllers/Inertia/CurrentUserController.php
index 20cce6c54..f20488c50 100644
--- a/src/Http/Controllers/Inertia/CurrentUserController.php
+++ b/src/Http/Controllers/Inertia/CurrentUserController.php
@@ -11,6 +11,19 @@
class CurrentUserController extends Controller
{
+ /**
+ * Delete the current user profile photo.
+ *
+ * @param Request $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function deleteProfilePhoto(Request $request)
+ {
+ $request->user()->deleteProfilePhoto();
+
+ return back()->with('status', 'profile-photo-deleted');
+ }
+
/**
* Delete the current user.
*
diff --git a/src/Http/Livewire/UpdateProfileInformationForm.php b/src/Http/Livewire/UpdateProfileInformationForm.php
index 9cf487838..55a27e53f 100644
--- a/src/Http/Livewire/UpdateProfileInformationForm.php
+++ b/src/Http/Livewire/UpdateProfileInformationForm.php
@@ -59,6 +59,20 @@ public function updateProfileInformation(UpdatesUserProfileInformation $updater)
$this->emit('saved');
}
+ /**
+ * Delete user's profile photo.
+ *
+ * @param \Laravel\Fortify\Contracts\UpdatesUserProfileInformation $updater
+ *
+ * @return void
+ */
+ public function deleteProfilePhoto(UpdatesUserProfileInformation $updater)
+ {
+ Auth::user()->deleteProfilePhoto();
+
+ return redirect()->route('profile.show');
+ }
+
/**
* Get the current user of the application.
*
diff --git a/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue b/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue
index 6558e4c49..14c9b9391 100644
--- a/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue
+++ b/stubs/inertia/resources/js/Pages/Profile/UpdateProfileInformationForm.vue
@@ -34,6 +34,10 @@
Select A New Photo
+
+ Delete Photo
+
+
@@ -103,6 +107,14 @@
},
methods: {
+ deleteProfilePhoto() {
+ this.$inertia.delete('/user/profile-photo', {
+ preserveScroll: true,
+ }).then(() => {
+ this.photoPreview = null
+ });
+ },
+
updateProfileInformation() {
if (this.$refs.photo) {
this.form.photo = this.$refs.photo.files[0]
diff --git a/stubs/livewire/resources/views/profile/update-profile-information-form.blade.php b/stubs/livewire/resources/views/profile/update-profile-information-form.blade.php
index a31c806f1..dbc00893c 100644
--- a/stubs/livewire/resources/views/profile/update-profile-information-form.blade.php
+++ b/stubs/livewire/resources/views/profile/update-profile-information-form.blade.php
@@ -42,6 +42,12 @@
Select A New Photo
+ @if($this->user->profile_photo_path)
+
+ Delete Photo
+
+ @endif
+
@endif