I am trying to return all Posts(Model:Post) which have no row in the PostsHistory Model.
My code is:
public function posts(){
return $this->hasMany('App\Post');
}
public function remaining_posts(){
$history = PostHistory::all()->pluck('id');
return $this->posts->whereNotIn('post_id', $history);
}
But I get an error
[BadMethodCallException]
Method whereNotIn does not exist.
Is there any way I could get the remaining_posts through a relationship or can only be done in the controller?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire