order('weigh desc,id desc') ->select(); $result = []; $tree = \fast\Tree::instance(); $tree->init(collection($categoryList)->toArray(), 'pid'); $CategoryIds = is_array($ids) ? $ids : explode(',', $ids); foreach ($CategoryIds as $index => $CategoryId) { $result = array_merge($result, $tree->getChildrenIds($CategoryId, $withself)); } // Cache::set($cacheName, $result); // } return $result; } /** * 根据分类ID获取分类信息 * @param array $arrCategoryIds 分类ID集合 * @return array */ public static function getCategoryByIds($arrCategoryIds = []){ $categoryList = Category::where('id', 'IN', $arrCategoryIds) ->where('status', StatusEnum::ENABLED) ->order('weigh desc,id desc') ->field('id,name,image,weigh,pid') ->select(); $arrCategory = collection($categoryList)->toArray(); return $arrCategory; } }