-
-
Save MuhamedPy/fb9676a839e7ca34ca1188ede6323af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (app()->getLocale() == 'ar'){ | |
\LaravelLocalization::setLocale('en'); | |
}else{ | |
\LaravelLocalization::setLocale('ar'); | |
} | |
$UrlPrevious = url()->previous(); | |
if(strpos(url()->previous(), '/p/') !== false){ | |
$UrlProduct= ltrim(strstr(url()->previous(),"/p/"),"/p/"); | |
$previousLang = request()->segment(1) ; | |
$slug = Product::where("slug_$previousLang",$UrlProduct) | |
->first() | |
->slug; | |
$UrlPrevious = str_replace($UrlProduct,$slug,$UrlPrevious) ; | |
}elseif (strpos(url()->previous(), '/s/') !== false || strpos(url()->previous(), '/f/') !== false){ | |
if (strpos(url()->previous(), '/s/')){ | |
$segment = '/s/'; | |
}else{ | |
$segment = '/f/'; | |
} | |
$UrlProduct= ltrim(strstr(url()->previous(),$segment),$segment); | |
$oldSlug = str_replace(strstr($UrlProduct,'?'),'',$UrlProduct) ; | |
$previousLang = request()->segment(1); | |
$slug = SubCategory::where("slug_$previousLang",$oldSlug) | |
->first() | |
->slug; | |
$UrlPrevious = str_replace($oldSlug,$slug,$UrlPrevious) ; | |
} | |
$url = \LaravelLocalization::getLocalizedURL(App::getLocale(), $UrlPrevious); | |
return redirect($url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment