Issue with getEloquentQuery, query and Action
I am doing this in a resource, it works good but for example if it is filtering $filter_stock = request()->query('filterStock'); and I click on an action, that query returns null and it still being in the url, how can I solve this?
5 Replies
that's not the behaviour that I need, I tried to solve it with Session but it makes errors if I have multiple tags opened
Put it on a Livewire property. The request() part is lost, when making Livewire requests.
Thank you I will investigate
Sorry, I don't understand how can I achieve it, I am trying to do this but gives me null
public static $filterUser;
public static $filterStock;
protected $queryString = [
'tableFilters',
'tableSortColumn',
'tableSortDirection',
'tableSearchQuery' => ['except' => ''],
'tableColumnSearchQueries',
'filterUser',
'filterStock'
];
At the beginning I tried to do it with the mount and access it with the $this-> but it is not compatible
Does anybody have an idea? I cannot find a solution 😦In the
mount()
method of your page, grab what you need from the request and put it in a global property (e.g. $this->filterStock = request()->query( ... )
)
Otherwise, as Dennis mentionned, the initial request()
is lost when Livewire is doing AJAX behind the scenes
Oh, I see what you mean! The getEloquentQuery()
method is static.
Use getTableQuery()
instead, on the page classThank you for the answer, yes that's the problem
I was trying to do a filter hidded but it does not work
Oh, I will try, thank you
It worked very good, thank you vary much, I spent many hours