mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-30 07:50:11 -06:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Note;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class NoteSearch extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public int $perPage = 25;
|
|
|
|
public string $search = '';
|
|
|
|
protected $queryString = [
|
|
'search' => ['except' => ''],
|
|
'page' => ['except' => 1],
|
|
'perPage' => ['except' => ''],
|
|
];
|
|
|
|
final public function updatedPage(): void
|
|
{
|
|
$this->emit('paginationChanged');
|
|
}
|
|
|
|
final public function updatingSearch(): void
|
|
{
|
|
$this->resetPage();
|
|
}
|
|
|
|
final public function getNotesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
|
{
|
|
return Note::query()
|
|
->with(['noteduser', 'staffuser'])
|
|
->when($this->search, fn ($query) => $query->where('message', 'LIKE', '%'.$this->search.'%'))
|
|
->latest()
|
|
->paginate($this->perPage);
|
|
}
|
|
|
|
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
|
{
|
|
return view('livewire.note-search', [
|
|
'notes' => $this->notes,
|
|
]);
|
|
}
|
|
}
|