<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Nav\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; use Module\Nav\Type\NavPosition; class NavUtil { const CACHE_KEY_PREFIX = 'nav:'; public static function add($qMgyC, $bIeOt, $Qh4CI) { $YXlAE = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $qMgyC, 'name' => $bIeOt, 'link' => $Qh4CI, 'sort' => $YXlAE)); } public static function listByPosition($qMgyC = 'header') { return ModelUtil::model('nav')->where(array('position' => $qMgyC))->orderBy('sort', 'asc')->get()->toArray(); } public static function listByPositionWithCache($qMgyC = 'header', $aTEKz = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $qMgyC, $aTEKz, function () use($qMgyC) { return self::listByPosition($qMgyC); }); } public static function clearCache() { foreach (NavPosition::getList() as $l0ek5 => $zYJ1g) { Cache::forget(self::CACHE_KEY_PREFIX . $l0ek5); } } }