From ffc3746e13bb9c3b6685cf4c798b93171a8a192f Mon Sep 17 00:00:00 2001 From: Ahmad Syamim Date: Thu, 31 Mar 2022 17:06:40 +0900 Subject: [PATCH 1/4] updates: check for column exists --- src/Controllers/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/Language.php b/src/Controllers/Language.php index 53e81b9..379c74b 100644 --- a/src/Controllers/Language.php +++ b/src/Controllers/Language.php @@ -21,7 +21,7 @@ private function setLocale($locale, $request) $locale = config('app.locale'); } - if (Auth::check()) { + if (Auth::check() && Auth::user()->getAttribute('locale') instanceof \Illuminate\Support\Collection) { Auth::user()->setAttribute('locale', $locale)->save(); } else { $request->session()->put('locale', $locale); From 60986a82ec0fc9a12504bc7f6923287cce19797b Mon Sep 17 00:00:00 2001 From: Ahmad Syamim Date: Thu, 31 Mar 2022 11:22:54 +0900 Subject: [PATCH 2/4] updates: check locale from session --- src/Middleware/SetLocale.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Middleware/SetLocale.php b/src/Middleware/SetLocale.php index 9f2b658..83e1a46 100644 --- a/src/Middleware/SetLocale.php +++ b/src/Middleware/SetLocale.php @@ -86,6 +86,8 @@ public function handle($request, Closure $next) { if ($request->has('lang')) { $this->setLocale($request->get('lang')); + } elseif ($request->session()->get('locale')) { + $this->setLocale($request->session()->get('locale')); } elseif (auth()->check()) { $this->setUserLocale(); } else { From 3553346f83ffb1062c12304578f57b1572181f37 Mon Sep 17 00:00:00 2001 From: Ahmad Syamim Date: Thu, 31 Mar 2022 11:23:59 +0900 Subject: [PATCH 3/4] updates: prevent multiple redirects --- src/Controllers/Language.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Controllers/Language.php b/src/Controllers/Language.php index 379c74b..40e1921 100644 --- a/src/Controllers/Language.php +++ b/src/Controllers/Language.php @@ -60,6 +60,8 @@ public function back($locale, Request $request) $url = config('language.back', 'session') === 'referer' ? $this->getUrlFromReferer($locale, $request) : $this->getUrlFromSession($locale, $request); + + $url = $request->url() == $url ? url('/') : $url; return redirect( $url From 1279a482ac1731f53a859f4f675e9e767f6d64c8 Mon Sep 17 00:00:00 2001 From: Ahmad Syamim Date: Fri, 27 Jan 2023 22:58:48 +0800 Subject: [PATCH 4/4] Update Language.php --- src/Controllers/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/Language.php b/src/Controllers/Language.php index 40e1921..c5cbc06 100644 --- a/src/Controllers/Language.php +++ b/src/Controllers/Language.php @@ -61,7 +61,7 @@ public function back($locale, Request $request) ? $this->getUrlFromReferer($locale, $request) : $this->getUrlFromSession($locale, $request); - $url = $request->url() == $url ? url('/') : $url; + $url = $request->url() == $url ? url('/') : $url; return redirect( $url