How to get current route and params inside updateStateUsing?

So i have a widget that will set a params to the url after click. But in the updateStateUsing i cant seems to get the params. What i have: 1. 'products/merchant_id=1' as url and i can access this at public static table function through request() helper. 2. I have a TextInputColumn and using updateStateUsing. when i dd(request()) inside updateStateUsing, it seems like the requests has been changed. Or am I in the right direction?
Solution:
You can take what you need from the request in the mount() method of your page and put it in a public property
Jump to solution
7 Replies
mango1026
mango1026OP17mo ago
Up.
Patrick Boivin
Patrick Boivin17mo ago
Don't do this, it's not reliable
Solution
Patrick Boivin
Patrick Boivin17mo ago
You can take what you need from the request in the mount() method of your page and put it in a public property
Patrick Boivin
Patrick Boivin17mo ago
Then access it like this
->updateStateUsing(function ($livewire) {
// use $livewire->my_property
})
->updateStateUsing(function ($livewire) {
// use $livewire->my_property
})
mango1026
mango1026OP17mo ago
By saying not reliable, do you mean updateStateUsing? Any recommendation is welcome too! This works fine for me thanks a lot.
Dennis Koch
Dennis Koch17mo ago
No he means accessing request(). You are getting different output because it's a Livewire request, so the URL has changed.
mango1026
mango1026OP17mo ago
Ah understand. Thanks for the input Dennis!
Want results from more Discord servers?
Add your server