model = $model; } /** * Returns a setting from the database. * * @param string $name * @param bool $checkEnv * * @return string|null */ public function get($name, $checkEnv = true) { // if we've not loaded the settings, load them now if (!$this->settings) { $this->settings = $this->model->all()->lists('value', 'name'); } // if the setting exists, return it if (isset($this->settings[$name])) { return $this->settings[$name]; } // fallback to getenv if allowed to if ($checkEnv) { return $this->settings[$name] = getenv(strtoupper($name)); } } /** * Creates or updates a setting value. * * @param string $name * @param string $value * * @return void */ public function set($name, $value) { // save the change to the db $this->model->updateOrCreate(compact('name'), compact('value')); // if we've loaded the settings, persist this change if ($this->settings) { $this->settings[$name] = $value; } } }