/** * 获取前台控制菜单列表 */ public function menus() { if ($menus = MenusModel::all()) { return Tools::getChild($menus, $pid = 0); } return []; }
/** * 数组中对象子id重组 */ public static function getChild($arrs, $pid = 0) { $list = array(); foreach ($arrs as $v) { if ($v->pid == $pid) { //找到子节点,继续找该子节点的后代节点 $v->child = Tools::getChild($arrs, $v->id); $list[] = $v; } } return $list; }
public static function getFooters() { return Tools::getChild(LinkModel::footers(), $pid = 0); }
public static function getActions() { return Tools::getChild(ActionModel::getAdminMenus(), $pid = 0); }
public static function getHeaders() { return Tools::getChild(LinkModel::headers(), $pid = 0); }
public static function getMemberMenus() { return Tools::getChild(MenusModel::MemberMenus(), $pid = 0); }
public static function getCompanyMenus() { return Tools::getChild(MenusModel::CompanyMenus(), $pid = 0); }
public static function getNavigates() { return Tools::getChild(LinkModel::navigates(), $pid = 0); }