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
Redirection from non-localized URLs to localized URLs does not work sometimes, because of LaravelLocalization::extractAttributes() behaviour : it does not match domain restrictions.
(More generally, getLocalizedURL does not work because of that.)
If you try to load https://www.tata.com/tutu/titiit will match toto route instead of tata route, and will redirect to : https://www.tata.com/en/tutu/{slug} instead of https://www.tata.com/en/tutu/titi !
Isn't it possible to get the route directly from laravel methods ? That way, we would be sure the route found is the correct one, even for futures Laravel updates on routing..?
Maybe like this ?
protected function extractAttributes($url = false, $locale = '')
{
if (!empty($url)) {
$route = collect(\Route::getRoutes())->first(function($route) use($url){
return $route->matches(request()->create($url));
});
/* generate $attributes from found $route */
[...]
Redirection from non-localized URLs to localized URLs does not work sometimes, because of
LaravelLocalization::extractAttributes()
behaviour : it does not match domain restrictions.(More generally,
getLocalizedURL
does not work because of that.)For instance :
If you try to load
https://www.tata.com/tutu/titi
it will matchtoto
route instead oftata
route, and will redirect to :https://www.tata.com/en/tutu/{slug}
instead ofhttps://www.tata.com/en/tutu/titi
!Isn't it possible to get the route directly from laravel methods ? That way, we would be sure the route found is the correct one, even for futures Laravel updates on routing..?
Maybe like this ?
where $url is the absolute url.
(credits : I found that solution here => https://stackoverflow.com/questions/24582922/laravel-get-route-name-from-given-url)
The text was updated successfully, but these errors were encountered: