diff --git a/app/Http/Controllers/Forum/ThreadsController.php b/app/Http/Controllers/Forum/ThreadsController.php index 1da75b1c9..37524b0c7 100644 --- a/app/Http/Controllers/Forum/ThreadsController.php +++ b/app/Http/Controllers/Forum/ThreadsController.php @@ -18,6 +18,7 @@ use App\Models\Tag; use App\Models\Thread; use App\Models\User; +use App\Notifications\ThreadDeletedNotification; use App\Policies\ThreadPolicy; use Illuminate\Auth\Middleware\Authenticate; use Illuminate\Auth\Middleware\EnsureEmailIsVerified; @@ -122,6 +123,12 @@ public function delete(Thread $thread) { $this->authorize(ThreadPolicy::DELETE, $thread); + request()->whenFilled('reason', function () use ($thread) { + $thread->author()?->notify( + new ThreadDeletedNotification($thread, request('reason')), + ); + }); + $this->dispatchSync(new DeleteThread($thread)); $this->success('forum.threads.deleted'); diff --git a/app/Notifications/ThreadDeletedNotification.php b/app/Notifications/ThreadDeletedNotification.php new file mode 100644 index 000000000..bfd12fc34 --- /dev/null +++ b/app/Notifications/ThreadDeletedNotification.php @@ -0,0 +1,33 @@ +line("The thread '{$this->thread->subject()}' #{$this->thread->getKey()} was deleted by the moderator") + ->line('with the following reasons:') + ->line($this->reason) + ->line('Thank you'); + } +} diff --git a/resources/views/components/threads/thread-menu.blade.php b/resources/views/components/threads/thread-menu.blade.php index f73ed4320..bbcf798ec 100644 --- a/resources/views/components/threads/thread-menu.blade.php +++ b/resources/views/components/threads/thread-menu.blade.php @@ -50,5 +50,6 @@ class="absolute top-12 right-1 flex flex-col bg-white rounded shadow w-48" title="Delete Thread" >
Are you sure you want to delete this thread and its replies? This cannot be undone.
+