You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the current localization system does not handle using field names in route parameters.
Example
Route definitions
french: /ville/{city:slug} --> default language
english: /city/{city:slug}
Using LaravelLocalization::getLocalizedURL() to get the english url, it will return /en/ville/{city:slug}.
After checking, it seems that when getting the attributes it ignores :slug and uses the key city and then tries to find {city} in the translated url to return it.
I wish to not use the route binding on my model as the id and other attributes are used in other places.
Thanks in advance !
The text was updated successfully, but these errors were encountered:
I switched my routes from /page/{model} to /page/{model:slug} and /some-other-page/{model:id} because in some routes I need to fetch same model via slug and in some via ID and package stopped to translate my routes.
Before routes switch I used this fix (which works for my specific use case where all routes that require slug starts with pages.), this isn't long-term solution and it would be good to fix this small bug:
public function getRouteKeyName()
{
return request()->route() && str_starts_with(request()->route()->getName(), 'pages.') ? 'slug' : 'id';
}
Right now, the current localization system does not handle using field names in route parameters.
Example
Route definitions
french:
/ville/{city:slug}
--> default languageenglish:
/city/{city:slug}
Using
LaravelLocalization::getLocalizedURL()
to get the english url, it will return/en/ville/{city:slug}
.After checking, it seems that when getting the attributes it ignores
:slug
and uses the keycity
and then tries to find {city} in the translated url to return it.I wish to not use the route binding on my model as the id and other attributes are used in other places.
Thanks in advance !
The text was updated successfully, but these errors were encountered: