Exemplo n.º 1
0
 /**
  * @param $key
  * @param null $default
  * @return null
  */
 public function get($key, $default = null)
 {
     try {
         $settings = $this->cache->rememberForever($this->cache_key, function () {
             $settings = Setting::get(['key', 'value']);
             $arr = [];
             foreach ($settings as $setting) {
                 $arr[$setting->key] = $setting->value;
             }
             return $arr;
         });
         return isset($settings[$key]) ? $settings[$key] : $default;
     } catch (Exception $ex) {
         return null;
     }
 }
Exemplo n.º 2
0
 /**
  * Cache all configurations.
  *
  * @return void
  */
 public function fetchAndCache()
 {
     $this->removeCache();
     $configs = $this->cache->rememberForever('cartalyst.config', function () {
         return $this->database->table($this->databaseTable)->get();
     });
     $cachedConfigs = [];
     foreach ($configs as $key => $config) {
         $value = $this->parseValue($config->value);
         $cachedConfigs[$config->item] = $value;
         parent::set($config->item, $value);
     }
     $this->cachedConfigs = $cachedConfigs;
 }
Exemplo n.º 3
0
 /**
  * @param $key
  * @param $data
  *
  * @return mixed
  */
 public function rememberForever($key, $data)
 {
     return $this->cache->rememberForever($key, function () use($data) {
         return $data;
     });
 }