Created
May 6, 2023 02:22
-
-
Save snellingio/89db1b14a9c30195f28d0c3cb2867dc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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