Пример #1
0
 /**
  * Sets and stores the locale in the session.
  *
  * @param SetLocaleRequest $request
  * @return mixed
  */
 public function setLocale(SetLocaleRequest $request)
 {
     $locale = $request->input('locale');
     if (!$this->repository->isAvailable($locale)) {
         return redirect()->back()->withErrors("Locale {$locale} is not available");
     }
     session()->set($this->getSessionKey(), $locale);
     return redirect()->back();
 }
Пример #2
0
 /**
  * Returns the session locale, replacing unavailable with default.
  *
  * @return bool|string
  */
 protected function getValidSessionLocale()
 {
     $locale = $this->getSessionLocale();
     if (!$locale) {
         return false;
     }
     if (!$this->repository->isAvailable($locale)) {
         $locale = $this->repository->getDefault();
     }
     return $locale;
 }