41 lines
986 B
PHP
41 lines
986 B
PHP
<?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
|
|
]);
|
|
}
|
|
}
|