public function clearCacheAction() { $compiled_path = rtrim(storage_path('framework/views/')); array_map('unlink', glob("{$compiled_path}*")); \Cache::flush(); \KSPM\LCMS\Model\SlugCache::truncate(); return json_encode(array('status' => true)); }
/** * @param string $str * @param int $base_id * @return string */ public static function getSlug($str, $base_id = false) { if (!$base_id) { $dbSlug = SlugCache::findByBaseStr($str); } else { $dbSlug = SlugCache::findByBaseData($str, $base_id); } if ($dbSlug) { return $dbSlug->slug; } $slug = strtolower(preg_replace('/[^A-Za-z0-9-]+/', '-', self::_generateSlugFromString($str))); SlugCache::updateOrCreate(array('slug' => $slug), array('base_str' => $str, 'slug' => $slug, 'base_id' => $base_id ? $base_id : 0)); return $slug; }
public static function findByBaseData($base_str, $base_id) { return SlugCache::firstByAttributes(array('base_str' => $base_str, 'base_id' => $base_id)); }