<?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($FcLCS, $L1N0l, $vkcuv) { $C6vyf = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $FcLCS, 'name' => $L1N0l, 'link' => $vkcuv, 'sort' => $C6vyf)); } public static function tree() { $jMboY = TreeUtil::modelToTree('nav', array('position' => 'position', 'name' => 'name', 'openType' => 'openType', 'link' => 'link', 'icon' => 'icon'), 'id', 'pid', 'sort', array('enable' => true)); return $jMboY; } public static function listByPosition($FcLCS = 'header') { $jMboY = self::tree(); return array_filter($jMboY, function ($jIWZA) use($FcLCS) { return $jIWZA['position'] == $FcLCS; }); } public static function listByPositionWithCache($FcLCS = 'header', $K9IuV = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $FcLCS, $K9IuV, function () use($FcLCS) { return self::listByPosition($FcLCS); }); } public static function hasData($FcLCS = 'header') { $aFDel = self::listByPositionWithCache($FcLCS); return !empty($aFDel); } public static function clearCache() { foreach (NavPosition::getList() as $kEhTf => $plloB) { Cache::forget(self::CACHE_KEY_PREFIX . $kEhTf); } } }