Filter On Load Or URL

Hi all I hope someone can help. I have a table in a livewire component ( not panel ). I have a link on another page which directs to this table page and modifies the query:
>modifyQueryUsing(function (Builder $query) {

// If client_id is in the GET
if (request()->filled('client_id')) {
$query->where('client_id', request()->input('client_id'));
}
}
>modifyQueryUsing(function (Builder $query) {

// If client_id is in the GET
if (request()->filled('client_id')) {
$query->where('client_id', request()->input('client_id'));
}
}
Howver when I click on the next page in the pagination it is lost. So I wondered if there a way to save this? OR Have a filter (client drop down) be selected on page load).
Solution:
if you yuse multiple() try [request()->input('client_id')] because i believe it want a array.
Jump to solution
5 Replies
David | Fortune Validator
Any ideas anyone? Sorry for the bump
Tieme
Tieme10mo ago
Does something like this works for you?
Tables\Filters\SelectFilter::make('client_id')
->relationship('client','name')
->default(fn() => request()->filled('client_id') ? request()->input('client_id') : null),
Tables\Filters\SelectFilter::make('client_id')
->relationship('client','name')
->default(fn() => request()->filled('client_id') ? request()->input('client_id') : null),
David | Fortune Validator
Unfortunatly this didnt work. As soon as you go to another pages its lost scrap that it works if I take off the ->multiple() which I can live with thank you ever so much
Solution
Tieme
Tieme10mo ago
if you yuse multiple() try [request()->input('client_id')] because i believe it want a array.
David | Fortune Validator
This makes sense. Thanks again.
Want results from more Discord servers?
Add your server