4, //公告 'help_center' => 2, //帮助中心 'agreement' => 3, //协议 'information' => 1, //资讯 'college' => 5, //学院 'grade_remark' => 35, //用户等级说明 'clause' => 11, //隐私条款 'marketAction' => 32, //市场动态 ]; public function sub_categorys() { return $this->hasMany(ArticleCategory::class, 'pid', 'id'); } //取出无限级子级 public static function getSubChildren($id, $subIds = []) { $categorys = ArticleCategory::query()->where('pid', $id)->select(['id', 'pid'])->get(); if (blank($categorys)) { return []; } else { $categorys = $categorys->toArray(); } $subIds = get_tree_child($categorys, $id); return $subIds; // $categorys = ArticleCategory::query()->where('pid',$id)->select(['id','pid'])->get(); // foreach ($categorys as $key=>$value){ // $subIds[] = $value['id']; // $category = ArticleCategory::query()->where('pid',$value['id'])->select(['id','pid'])->get(); // if($category){ // $subIds = self::getSubChildren($value['id'],$subIds); // } // } // return $subIds; } //系统公告 public function category_translations() { return $this->belongsTo(CategoryTranslations::class, 'id', 'category_id'); } }