2
我试图返回PostsHistory模型中没有行的所有帖子(型号:Post)。Laravel relationship`whereNotIn`其他表
我的代码是:
public function posts(){
return $this->hasMany('App\Post');
}
public function remaining_posts(){
$history = PostHistory::all()->pluck('id');
return $this->posts->whereNotIn('post_id', $history);
}
但我得到一个错误
[BadMethodCallException]
Method whereNotIn does not exist.
有什么办法,我可以通过关系拿到remaining_posts或只能在控制器内完成?
感谢您的解释:) – George