<?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($v1C6R, $SeTC_, $GGM4j) { $xJD2B = intval(ModelUtil::max('nav', 'sort')) + 1; ModelUtil::insert('nav', array('position' => $v1C6R, 'name' => $SeTC_, 'link' => $GGM4j, 'sort' => $xJD2B)); } public static function tree() { $WOwU2 = TreeUtil::modelToTree('nav', array('position' => 'position', 'name' => 'name', 'openType' => 'openType', 'link' => 'link', 'icon' => 'icon'), 'id', 'pid', 'sort', array('enable' => true)); return $WOwU2; } public static function listByPosition($v1C6R = 'header') { $WOwU2 = self::tree(); return array_filter($WOwU2, function ($zEBpl) use($v1C6R) { return $zEBpl['position'] == $v1C6R; }); } public static function listByPositionWithCache($v1C6R = 'header', $COWz6 = 600) { return Cache::remember(self::CACHE_KEY_PREFIX . $v1C6R, $COWz6, function () use($v1C6R) { return self::listByPosition($v1C6R); }); } public static function hasData($v1C6R = 'header') { $GMPEM = self::listByPositionWithCache($v1C6R); return !empty($GMPEM); } public static function clearCache() { foreach (NavPosition::getList() as $d2HEV => $K0KRy) { Cache::forget(self::CACHE_KEY_PREFIX . $d2HEV); } } }