chaoyu/app/widget/Menu.php

25 lines
605 B
PHP
Raw Normal View History

<?php
namespace app\widget;
use think\facade\{View, Cache};
use app\model\Category;
class Menu
{
public function index($categoryId)
{
$menus = Cache::get('rules');
if(empty($menus)){
$menus = Category::getListForFrontMenu();
}
$currentFirstId = 0;
if (is_numeric($categoryId) && $categoryId > 0) {
$currentFirstId = Category::firstGradeById($categoryId);
}
$data = [
'categoryId' => $categoryId,
'menus' => $menus,
];
return View::assign($data)->fetch('public/menu');
}
}