Grab a setting from cached Settings table by slug.
Cache lifetime: 60 minutes.

@param $slug

@return mixed
336297
public static function grab($slug)
    {
        /*
         * Comment out prior to 0.2 launch. Will cause massive amount
         * of Database queries. Only for adding new settings while
         * in development and testing.
         */
        //       Cache::flush();

        $setting = Cache::remember('ticketit::settings.'.$slug, 60, function () use ($slug) {
            $settings = Cache::remember('ticketit::settings', 60, function () {
                return Table::all();
            });

            $setting = $settings->where('slug', $slug)->first();

            if ($setting->lang) {
                return trans($setting->lang);
            }

            if (self::is_serialized($setting->value)) {
                $setting = unserialize($setting->value);
            } else {
                $setting = $setting->value;
            }

            return $setting;
        });

        return $setting;
    }
503513
public function get($key)
    {
        if (isset($this->cache[$key])) {
            list($expires, $value) = $this->cache[$key];
            if (!$expires || ($expires >= microtime(true))) {
                return $value;
            }
            unset($this->cache[$key]);
        }
        return false;
    }
234825
public function getValuelistBySlug($slug)
    {
        $valuelists = $this->repository->valuelists;
        foreach ($valuelists as $valuelist) {
            if ($valuelist->slug == $slug) {
                return $valuelist;
            }
        }

        return null;
    }
1022949
public function get($slug){
        return empty($this->index[$slug]) ? null : $this->index[$slug];
    }
899814
public function getThemePath($slug)
    {
        if (Str::length($slug) > 3) {
            $theme = Str::studly($slug);
        } else {
            $theme = Str::upper($slug);
        }

        return $this->getThemesPath() .DS .$theme .DS;
    }
674035
public function getCacheLifetime()
    {
        if ($this->cacheLifetime === null) {
            $this->setCacheLifetime($this->config->get('concrete.i18n.community_translation.cache_lifetime', 3600));
        }

        return $this->cacheLifetime;
    }
1260889
public function forget($key)
    {
        $isDeleted = SettingModel::where('key', $key)
            ->delete();

        // if delete record then delete cache
        if ($isDeleted) {
            Cache::forget('Klaravel\Settings\Setting');
        }

        return $isDeleted;
    }
878928
public function getPlugin($slug)
    {
        $this->plugins->rewind();
        while ($this->plugins->valid()) {
            if ($this->plugins->current()->getSlug() == $slug) {
                return $this->plugins->current();
            }
            $this->plugins->next();
        }

        return false;
    }
685828
public function getExpiry($key)
    {
        $key = $this->getPrefix().$key;
        if (!$this->isInCache($key)) {
            return false;
        }

        return $this->fetchExpirationFromCache($key);
    }
479313
public function view($slug = null)
    {
        //The category can be passed as query string, from a widget
        if ($this->request->getQuery('q')) {
            return $this->redirect([$this->request->getQuery('q')]);
        }

        $page = $this->request->getQuery('page', 1);

        //Sets the cache name
        $cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($posts, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsCategories->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($posts) || empty($paging)) {
            $query = $this->PostsCategories->Posts->find('active')
                ->find('forIndex')
                ->where([sprintf('%s.slug', $this->PostsCategories->getAlias()) => $slug]);

            is_true_or_fail(!$query->isEmpty(), I18N_NOT_FOUND, RecordNotFoundException::class);

            $posts = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $posts,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsCategories->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set('category', $posts->extract('category')->first());
        $this->set(compact('posts'));
    }
453190
public function getSetting($key)
    {
        if (!isset($this->_settings[$key])) {
            return null;
        }
        return $this->_settings[$key];
    }
256451
private function checkUpdatingSlug($slug)
    {
        if ($this->id >= 1) {

            $found = false;
            foreach ($this->uniqueModels() as $class) {

                // find entries matching slug, exclude updating entry
                $builder = $this->eloqent($class)->where('slug', $slug);

                // same model - exlude check
                if ($class == self::class) {
                    $builder = $builder->where('id', '!=', $this->id);
                }

                // found same slug - break, need new slug
                if ($found = $builder->first()) {
                    break;
                }
            }

            // save to use current slug for update
            if ($found == false || $found == null) {
                return $slug;
            }
        }

        // new unique slug needed
        return false;
    }
336061
public function getCacheVer($table)
    {
        if (!$this->openCache) {
            return '';
        }

        $version = Model::getInstance()->cache()->get($this->conf['mark'] . '_db_cache_version_' . $table);
        if (!$version) {
            $version = microtime(true);
            Model::getInstance()->cache()->set($this->conf['mark'] . '_db_cache_version_' . $table, $version, $this->conf['cache_expire']);
        }
        return $version;
    }
56767
public function fetchBySlug($slug) {
        $select = $this->select()->where('slug = ?', $slug);
        return $this->fetchRow($select);
    }
102786
public function findActiveBySlug($slug, $host)
    {
        $query = $this->createValuedQueryBuilder('c')
            ->leftJoin('c.site', 'os')
            ->leftJoin('os.domains', 'd')
            ->where('c.slug = :slug')
            ->andWhere('c.active = :active')
            ->andWhere('c.layout = :layout')
            ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')
            ->andWhere('d.domain = :host OR c.site IS NULL')
            ->setParameters([
                'slug' => $slug,
                'active' => true,
                'layout' => false,
                'now' => new \DateTime(),
                'host' => $host
            ])
            ->getQuery();

        return $query->getSingleResult();
    }
734750
public static function removeDate($slug)
    {
        $slug = trim($slug, '/');
        while (preg_match('/^\d{4}\/\d{2}\/\d{2}\/?(\S+)?/', $slug, $m)) {
            $slug = trim(isset($m[1]) ? $m[1] : '', '/');
        }
        return $slug;
    }
1086680
protected function getContentBySlug($slug) {
        $this->CmsContent = TableRegistry::get('CmsContent');
        $query = $this->CmsContent->find('all');
        $query->where(['name' => $slug]);
        $data = $query->first();
        return $data;
    }