Admin: Add comments overview for moderation

This commit is contained in:
2025-10-29 15:59:43 +01:00
parent 59d63abd79
commit 9ca2f73714
6 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Facades\DB;
class AdminCommentSearch extends Component
{
use WithPagination;
public $search = '';
public $userSearch = '';
public function updatingSearch(): void
{
$this->resetPage();
}
public function updatingUserSearch(): void
{
$this->resetPage();
}
public function render()
{
$comments = DB::table('comments')
->join('users', 'comments.commenter_id', '=', 'users.id')
->select('comments.*', 'users.username')
->when($this->search !== '', fn ($query) => $query->where('comment', 'LIKE', "%$this->search%"))
->when($this->userSearch !== '', fn ($query) => $query->where('username', 'LIKE', "%$this->userSearch%"))
->paginate(12);
return view('livewire.admin-comment-search', [
'comments' => $comments
]);
}
}