<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Nav\Util; use Illuminate\Support\Facades\Cache; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\TreeUtil; use Module\Nav\Type\NavPosition; class NavUtil { const CACHE_KEY_PREFIX = 'nav:'; public static function add($zeOUe, $zO6V5, $NOEEy) { $pPq0i = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $zeOUe, 'name' => $zO6V5, 'link' => $NOEEy, 'sort' => $pPq0i)); } public static function tree() { $LoSrg = TreeUtil::modelToTree('nav', array('position' => 'position', 'name' => 'name', 'openType' => 'openType', 'link' => 'link', 'icon' => 'icon'), 'id', 'pid', 'sort', array('enable' => true)); return $LoSrg; } public static function listByPosition($zeOUe = 'head') { $LoSrg = self::tree(); return array_filter($LoSrg, function ($YaV4m) use($zeOUe) { return $YaV4m['position'] == $zeOUe; }); } public static function listByPositionWithCache($zeOUe = 'head', $Vr9BY = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $zeOUe, $Vr9BY, function () use($zeOUe) { return self::listByPosition($zeOUe); }); } public static function hasData($zeOUe = 'head') { $YPKfi = self::listByPositionWithCache($zeOUe); return !empty($YPKfi); } public static function clearCache() { foreach (NavPosition::getList() as $KAKiA => $NMB1l) { Cache::forget(self::CACHE_KEY_PREFIX . $KAKiA); } } }