i want to remove some post that have specific restrict value the posts are 2 type (artists and songs) , songs belong artists
i get the songs of artist by below code but when i use where function to remove some songs its not working ang got error
Error :
explode() expects parameter 2 to be string, object given
My Code
$rel = collect([]);
foreach ($post->artists as $artist) {
$artist_posts = $artist->getPosts->where(function ($query) {
$query->whereNotIn('restrict', ['res1'])->orWhereNull('restrict');
})->sortbydesc('id');
$rel = $rel->concat($artist_posts->where('type', $type));
}
$col = $rel->unique('id');
Post.php (model)
...
public function getPosts()
{
return $this->belongsToMany(Post::class, 'artists_posts', 'artist_id', 'post_id')->with('artists');
}
...
$type? also why are you passing a closure towhere... that isCollection@wherenot a Query BuilderwhereArtistnotPost?