where('status','>',-1) ->field(['id','pid','title','sort','display']) ->order('sort asc,id asc'); if (isset($where['status']) && $where['status'] != '') $model = $model->where("status",$where['status']); if (isset($where['title']) && $where['title'] != '') $model = $model->where("title|id","like","%$where[title]%"); $data = $model->select(); return $data->toArray() ?: []; } /** * 查询分类选择类型 * @param int $type * @param array $ids * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function selectByType(int $type = 0,array $ids = []) { $model = new self; if (!empty($ids)) $model = $model->where("id","not in", $ids); if ($type != 0) $model = $model->where("type",$type); $model = $model->where("status",1); $model = $model->field("id,title"); $data = $model->select(); return $data ? $data->toArray() : []; } }