|null */ private ?array $values = null; public function get(string $key, string $default) : string { $value = $this->all()[$key] ?? null; return ($value === null || trim($value) === '') ? $default : $value; } /** @param array $values */ public function setMany(array $values) : void { foreach ($values as $key => $value) { GlobalSetting::updateOrCreate(['key' => $key], ['value' => $value]); } $this->values = null; } /** @return array */ private function all() : array { return $this->values ??= GlobalSetting::pluck('value', 'key')->all(); } }