How to remove route parameters?
cod3rshotout opened this issue · comments
Hi, thanks for your library first of all!
I'm having a problem using Route::localizedUrl
, in particular, some routes are defined in this way:
Route::get('/form-and-function', 'Webkul\Shop\Http\Controllers\FrontendController@formAndFunction')->defaults('_config', [
'view' => 'shop::layouts.pages.form-and-function'
])->name('shop.frontend.pages.form_and_function');
so calling localizedUrl
will return:
https://example.com/it/form-and-function?_config%5Bview%5D=shop%3A%3Alayouts.pages.form-and-function
is there any way to remove all the parameters from the url and keep only https://example.com/it/form-and-function
Thanks
Hi,
This wasn't possible yet, but I've just added an option to exclude the query string:
Route::localizedUrl($locale = null, $parameters = null, $absolute = true, $keepQuery = true);
I'll tag it in a sec.
@ivanvermeyen thanks for the update but I still have the parameters .. seems the following line should be updated:
if ($url = $this->generateFromNamedRoute($locale, $parameters, $absolute)) {
dd($url);
return empty($query) && $keepQuery ? $url . $urlBuilder->getQueryString() : $url;
}
Essentially $url
contains this: https://example.com/it/form-and-function?_config%5Bview%5D=shop%3A%3Alayouts.pages.form-and-function
. But should contains only: https://example.com/it/form-and-function
, so even specifying keepQuery
on true, the parameters are still there.
Did you set $keepQuery
to false
to not show the query?
If true
it will show the query. (which is the default)
@ivanvermeyen yes, I set it, but as I said generateFromNamedRoute
return the url with the query string, so even though $keepQuery
is false, I get the parameters. Guess the same parameter should be passed to generateFromNamedRoute
Query parameters passed to the function (or defaults in your case) were not removed.
Should be fixed now in 2.10.1 👍