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'); + } +};