where('name', 'LIKE', "%$name%"); return self::tidyMenuTier($model->select(), 0); } public static function tidyMenuTier($menusList, $pid = 0, $navList = []) { foreach ($menusList as $k => $menu) { $menu = $menu->getData(); if ($menu['pid'] == $pid) { unset($menusList[$k]); $menu['child'] = self::tidyMenuTier($menusList, $menu['id']); $navList[] = $menu; } } return $navList; } /** * 获取分类下拉列表 * @param int $id * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getCateList($id = 10000, $type = 0) { $model = new self(); if ($id == 0) $model->where('pid', $id); if ($type == 1) return sort_list_tier($model->where('pid', 0)->select()->toArray()); return sort_list_tier($model->select()->toArray()); } /** * 获取单条信息 * @param $att_id * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getinfo($att_id) { $model = new self; $where['att_id'] = $att_id; return $model->where($where)->select()->toArray()[0]; } }