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