belongsTo('Article','article_id','id'); } public function user() { //评论关联用户 return $this->belongsTo('User','user_id','id'); } //获取评论 public function getComment($id) { $comments = $this::where(['article_id'=>$id,'status'=>1])->order(['cai'=>'asc','create_time'=>'asc'])->paginate(10); return $comments; } }