@@ 55-72 (lines=18) @@ | ||
52 | * |
|
53 | * @return string |
|
54 | */ |
|
55 | public static function default(): string |
|
56 | { |
|
57 | $default = Cache::get('locale_default'); |
|
58 | ||
59 | if ($default === null) |
|
60 | { |
|
61 | $default = static::query() |
|
62 | ->select('locale') |
|
63 | ->where('is_default', '=', true) |
|
64 | ->first(); |
|
65 | ||
66 | $default = !empty($default) ? $default->locale : config('contentful.default_locale'); |
|
67 | // Cache is cleaned in Console\Commands\SyncLocales (run at least daily) |
|
68 | Cache::forever('locale_default', $default); |
|
69 | } |
|
70 | ||
71 | return $default; |
|
72 | } |
|
73 | ||
74 | ||
75 | public static function getAppOrDefaultLocale(): string |
|
@@ 90-106 (lines=17) @@ | ||
87 | * |
|
88 | * @return string |
|
89 | */ |
|
90 | public static function defaultCountry(): string |
|
91 | { |
|
92 | $default = Cache::get('country_default'); |
|
93 | ||
94 | if ($default === null) |
|
95 | { |
|
96 | $default = static::query() |
|
97 | ->select('country') |
|
98 | ->where('is_default', '=', true) |
|
99 | ->first(); |
|
100 | $default = !empty($default) ? $default->country : config('contentful.default_country'); |
|
101 | // Cache is cleaned in Console\Commands\SyncLocales (run at least daily) |
|
102 | Cache::forever('country_default', $default); |
|
103 | } |
|
104 | ||
105 | return $default; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * Return fallback code for given locale code. |