Ejemplo n.º 1
0
 private function getLocale()
 {
     if (app()->runningInConsole()) {
         return null;
     }
     $host = \Site::host(true);
     $cacheKey = 'site_locale_' . $host;
     $locale = Cache::get($cacheKey);
     if (empty($locale)) {
         $siteLocale = \App\Models\SiteLocale::where('url', 'LIKE', '%' . $host)->first();
         if (empty($siteLocale)) {
             $error = 'No SiteLocale defined on the database level for host ' . $host;
             throw new \Exception($error);
         }
         $locale = $siteLocale->locale;
     }
     $expiresAt = Carbon::now()->addMinutes(10);
     Cache::put($cacheKey, $locale, $expiresAt);
     return $locale;
 }