Closed nishpatel closed 1 year ago
I don't understand what the problem is here exactly. What is happening and what are you expecting to happen instead?
What does route('catalog', { fallbackPlaceholder: 'mens/blazers?&filter[material][in][]=169' });
output?
Hi so when you add query params in we are getting this:
https://test.com/uk/mens/blazers%3F%26filter%5Bmaterial%5D%5Bin%5D%5B%5D%3D169'
When you decode you get this:
https://test.com/uk/mens/blazers?&filter[material][in][]=169
Obviously passing the first route will not work if you follow?
What is your catalog
route definition?
I'm not sure you're using fallback routes correctly—I don't think you would ever actually pass a value into the fallbackPlaceholder
parameter. fallbackPlaceholder
is injected by Laravel to make it possible to access the URL path inside your fallback route handler:
Route::fallback(function (Request $request, $fallbackPlaceholder) {
// This route is only run when no other route in the application matches the request
// E.g. if you don't have a route at `example.com/foo/bar/baz/bing` and it would normally 404,
// instead you can handle it here, and $fallbackPlaceholder will be 'foo/bar/baz/bing' so that you
// can figure out where the user intended to go and do something based on that
});
If you're trying to manually direct a user to the exact URL at test.com/uk/mens/blazers?&filter[material][in][]=169
you should do that, using it as a string instead of passing it through Ziggy.
If you're trying to direct them to test.com/uk
with a default category of mens/blazers?&filter[material][in][]=169
, you should navigate them to test.com/uk
and then check for a category value in your controller and set a default there if it's missing.
Is that what you're trying to do and does that make sense?
Closing this for now because I don't think it's an issue with Ziggy, but feel free to comment here if you have more info to add or any other questions.
Ziggy version
1.4.6
Laravel version
v8.83.24
Description
Any fallback URL will need to be decoded e.g.
decodeURIComponent(route('catalog', { fallbackPlaceholder: 'mens/blazers?&filter[material][in][]=169' }));
The issue is without decodeURIComponent the URL would simply go to a 404.
Ziggy call and context
Ziggy configuration
Route definition