Files
UNIT3D-Community-Edition/app/Http/Livewire/NoteSearch.php
HDVinnie 472c820f99 update: UNIT3D linting
- github action updated with new ruleset in pint.json
- codebase linted with new ruleset
- contributors can now run `./vendor/bin/pint`
- action workflow will auto correct any lint issues upon commit/opened pull request
2023-02-02 08:02:34 -05:00

54 lines
1.3 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 paginationView(): string
{
return 'vendor.pagination.livewire-pagination';
}
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,
]);
}
}