<?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($z8wh0, $MGY9H, $p1eFH) { $S0SDS = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $z8wh0, 'name' => $MGY9H, 'link' => $p1eFH, 'sort' => $S0SDS)); } public static function tree() { $Yap9t = TreeUtil::modelToTree('nav', array('position' => 'position', 'name' => 'name', 'openType' => 'openType', 'link' => 'link', 'icon' => 'icon'), 'id', 'pid', 'sort', array('enable' => true)); return $Yap9t; } public static function listByPosition($z8wh0 = 'header') { $Yap9t = self::tree(); return array_filter($Yap9t, function ($Z32UA) use($z8wh0) { return $Z32UA['position'] == $z8wh0; }); } public static function listByPositionWithCache($z8wh0 = 'header', $seQTq = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $z8wh0, $seQTq, function () use($z8wh0) { return self::listByPosition($z8wh0); }); } public static function hasData($z8wh0 = 'header') { $Zrrbp = self::listByPositionWithCache($z8wh0); return !empty($Zrrbp); } public static function clearCache() { foreach (NavPosition::getList() as $MFVkb => $FViDa) { Cache::forget(self::CACHE_KEY_PREFIX . $MFVkb); } } }