Skip to content

Commit

Permalink
Merge pull request #53 from ARCANEDEV/patch-cookies
Browse files Browse the repository at this point in the history
Updating the LocaleCookieRedirect Middleware
  • Loading branch information
arcanedev-maroc authored Aug 5, 2016
2 parents 2b31c16 + f7e7131 commit a9cf9af
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Middleware/LocaleCookieRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,13 @@ public function handle(Request $request, Closure $next)
$locale = $request->cookie('locale', null);

if (localization()->isLocaleSupported($segment)) {
cookie('locale', $segment);

return $next($request);
}
elseif (localization()->isDefaultLocaleHiddenInUrl()) {
$locale = localization()->getDefaultLocale();
cookie('locale', $locale);
return $next($request)->withCookie(cookie()->forever('locale', $segment));
}

if (is_string($locale) && ! $this->isDefaultLocaleHidden($locale)) {
session()->reflash();

$redirect = $this->getLocalizedRedirect($locale);

if ( ! is_null($redirect)) return $redirect;
if ($locale !== null && ! $this->isDefaultLocaleHidden($locale)) {
if ( ! is_null($redirect = $this->getLocalizedRedirect($locale))) {
return $redirect->withCookie(cookie()->forever('locale', $segment));
}
}

return $next($request);
Expand Down

0 comments on commit a9cf9af

Please sign in to comment.