Skip to content

Instantly share code, notes, and snippets.

@snellingio
Created May 6, 2023 02:22
Show Gist options
  • Save snellingio/89db1b14a9c30195f28d0c3cb2867dc9 to your computer and use it in GitHub Desktop.
Save snellingio/89db1b14a9c30195f28d0c3cb2867dc9 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Livewire;
use App\Models\User;
use Livewire\Component;
use Livewire\WithPagination;
class SearchComponent extends Component
{
use WithPagination;
#[URL]
public $search;
#[Getter]
public function users()
{
return User::search($this->search)->paginate(10);
}
public function render()
{
return <<<'BLADE'
<div>
<input wire:model.live="search" type="text" placeholder="Search " class="relative max-w-[45ch]"/>
<ul>
@foreach($users as $user)
<li class="idk???">{{ $user->name }}</li>
@endforeach
</ul>
<div wire:loading><div class="absolute right-0 top-0 bottom-0 flex items-center justify-center">
Spinner component...
</div></div>
</div>
BLADE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment