I tried to explain the purpose in words, but it was difficult, so I used images.
To explain it in words
Enter the search text.
Turn the page.
Delete the search text.
Result
Before
Only the search query string will be deleted.
After
Both page query and search query will be deleted.
Component
public $search = ‘’;
public $page = 1;
protected $queryString =
[
‘search’ => [‘except’ => ‘’],
‘page’ => [‘except’ => 1],
];
public function render()
{
$search = $this->search;
$sampledata =Sampledata::where(‘first_name’,‘like’,"%$search%")->latest()->paginate(3);
return view(‘livewire.posts’,compact(‘sampledata’));
}
I hope this is understood.(´∀`)