diff --git a/app/models/Setting.php b/app/models/Setting.php index 5685975f..3a8d51af 100644 --- a/app/models/Setting.php +++ b/app/models/Setting.php @@ -1,13 +1,44 @@ first()->value; - } catch (ErrorException $e) { - $setting = null; + $setting = self::whereName($settingName)->first()->value; + } catch (\ErrorException $e) { + // If we don't have a setting, check the env (fallback for original version) + if ($checkEnv) { + if (!($setting = getenv(strtoupper($settingName)))) { + self::unknownSettingException($settingName); + } + } else { + self::unknownSettingException($settingName); + } } return $setting; } + + /** + * Throws an BadConfigKeyException + * @param string $setting + * @throws BadConfigKeyException + * @return void + */ + public static function unknownSettingException($setting) { + throw new BadConfigKeyException( + sprintf('Unknown setting %s', $settingName) + ); + } } diff --git a/app/views/layout/master.blade.php b/app/views/layout/master.blade.php index d83b6d55..2c8a774b 100644 --- a/app/views/layout/master.blade.php +++ b/app/views/layout/master.blade.php @@ -3,7 +3,7 @@ - {{ getenv('APP_NAME') }} | Cachet + {{ Setting::get('app_name') }} | Cachet