From 75f631c3e6b8f9bde9443e72d700ec1188716254 Mon Sep 17 00:00:00 2001 From: w33b Date: Wed, 6 May 2026 21:08:51 +0200 Subject: [PATCH] Add MogLog System --- app/Livewire/Comment.php | 7 +++++ app/Models/ModLog.php | 18 ++++++++++++ ...026_05_06_181115_create_mod_logs_table.php | 29 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 app/Models/ModLog.php create mode 100644 database/migrations/2026_05_06_181115_create_mod_logs_table.php diff --git a/app/Livewire/Comment.php b/app/Livewire/Comment.php index 987ee79..73ca329 100644 --- a/app/Livewire/Comment.php +++ b/app/Livewire/Comment.php @@ -4,6 +4,7 @@ namespace App\Livewire; use App\Enums\UserRole; use App\Models\Episode; +use App\Models\ModLog; use App\Models\User; use App\Notifications\CommentNotification; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; @@ -71,6 +72,12 @@ class Comment extends Component $user = Auth::user(); if ($user->hasRole(UserRole::ADMINISTRATOR) || $user->hasRole(UserRole::MODERATOR)) { + // Log to ModLog + ModLog::create([ + 'moderator' => $user->name, + 'data' => "Deleted comment {$this->comment->id} written by {$this->comment->user->id} with contents: {$this->comment->body}", + ]); + $this->comment->deleted_by_moderator_id = $user->id; $this->comment->save(); $this->dispatch('refresh'); diff --git a/app/Models/ModLog.php b/app/Models/ModLog.php new file mode 100644 index 0000000..1380b67 --- /dev/null +++ b/app/Models/ModLog.php @@ -0,0 +1,18 @@ +id(); + $table->string('moderator'); + $table->text('data'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('mod_logs'); + } +};