<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Article\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; use Module\Article\Type\ArticlePosition; class ArticleUtil { const CACHE_KEY_PREFIX = 'article:'; public static function get($WXJys) { return ModelUtil::get('article', $WXJys); } public static function getByAlias($YJIbv) { return ModelUtil::get('article', array('alias' => $YJIbv)); } public static function listByPosition($qMgyC = 'home') { return ModelUtil::model('article')->where(array('position' => $qMgyC))->orderBy('sort', 'asc')->get()->toArray(); } public static function listByPositionWithCache($qMgyC = 'home', $aTEKz = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $qMgyC, $aTEKz, function () use($qMgyC) { return self::listByPosition($qMgyC); }); } public static function clearCache() { foreach (ArticlePosition::getList() as $l0ek5 => $zYJ1g) { Cache::forget(self::CACHE_KEY_PREFIX . $l0ek5); } } }