| @@ 52-65 (lines=14) @@ | ||
| 49 | * |
|
| 50 | * @return string |
|
| 51 | */ |
|
| 52 | public static function default(): string |
|
| 53 | { |
|
| 54 | $default = Cache::get('locale_default'); |
|
| 55 | ||
| 56 | if ($default === null) { |
|
| 57 | $default = static::query()->select('code')->where('is_default', '=', true)->first(); |
|
| 58 | $default = !empty($default) ? $default->code : config('contentful.default_locale'); |
|
| 59 | $default = self::getLocale($default); |
|
| 60 | // Cache is cleaned in Console\Commands\SyncLocales (run at least daily) |
|
| 61 | Cache::forever('locale_default', $default); |
|
| 62 | } |
|
| 63 | ||
| 64 | return $default; |
|
| 65 | } |
|
| 66 | ||
| 67 | ||
| 68 | public static function getAppOrDefaultLocale(): string |
|
| @@ 83-99 (lines=17) @@ | ||
| 80 | * |
|
| 81 | * @return string |
|
| 82 | */ |
|
| 83 | public static function defaultCountry(): string |
|
| 84 | { |
|
| 85 | $default = Cache::get('country_default'); |
|
| 86 | ||
| 87 | if ($default === null) { |
|
| 88 | $default = static::query() |
|
| 89 | ->select('code') |
|
| 90 | ->where('is_default', '=', true) |
|
| 91 | ->first(); |
|
| 92 | $default = !empty($default) ? $default->code : config('contentful.default_country'); |
|
| 93 | $default = self::getCountry($default); |
|
| 94 | // Cache is cleaned in Console\Commands\SyncLocales (run at least daily) |
|
| 95 | Cache::forever('country_default', $default); |
|
| 96 | } |
|
| 97 | ||
| 98 | return $default; |
|
| 99 | } |
|
| 100 | ||
| 101 | /** |
|
| 102 | * Return fallback code for given locale code. |
|