<?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($A0M_7, $aVT3z, $KH7AV) { $wuamL = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $A0M_7, 'name' => $aVT3z, 'link' => $KH7AV, 'sort' => $wuamL)); } public static function tree() { $rNN1B = TreeUtil::modelToTree('nav', array('position' => 'position', 'name' => 'name', 'openType' => 'openType', 'link' => 'link', 'icon' => 'icon'), 'id', 'pid', 'sort', array('enable' => true)); return $rNN1B; } public static function listByPosition($A0M_7 = 'header') { $rNN1B = self::tree(); return array_filter($rNN1B, function ($FSL7c) use($A0M_7) { return $FSL7c['position'] == $A0M_7; }); } public static function listByPositionWithCache($A0M_7 = 'header', $W7jBq = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $A0M_7, $W7jBq, function () use($A0M_7) { return self::listByPosition($A0M_7); }); } public static function hasData($A0M_7 = 'header') { $SG_3V = self::listByPositionWithCache($A0M_7); return !empty($SG_3V); } public static function clearCache() { foreach (NavPosition::getList() as $D5qRP => $FtPNG) { Cache::forget(self::CACHE_KEY_PREFIX . $D5qRP); } } }