Hi @skywalker,
thanks for your reply but I’m not sure if we are in the same page
the search works fine , and when there is no data I’m just putting simple html no data found , but after that if you write anything in the search box the requests are going forever in a loop.
this is my blade :
<input wire:model='filters.search' placeholder='Search ' />
and then
I’ve this in my controller
public $filters = [
'search' => '',
'location' => null,
'team' => null,
'title' => '',
];
then
public function getUsersQueryProperty()
{
$query = User::query()
->when($this->filters['location'], fn($query, $location) => $query->where('location', $location))
->when($this->filters['team'], fn($query, $team) => $query->where('team', $team))
->when($this->filters['title'], fn($query, $title) => $query->where('title', 'like', '%'.$title.'%'));
$this->applySearch($query);
return $this->applySorting($query);
}
function applySearch($query)
{
$query->when($this->filters['search'], fn($query, $search) => $query->where('name', 'like', '%'.$search.'%'));
return $query;
}
public function getUsersProperty()
{
//return $this->applyPagination($this->usersQuery);
return $this->cache(function () {
return $this->applyPagination($this->usersQuery);
});
}
public function render()
{
if($this->selectAll)
{
$this->selected = $this->usersQuery->pluck('id');
}
return view('livewire.apps.users.users',
[
'users' => $this->users,
]);
}