Level 51
you can create additional relationships filtered by banner type on the pivot
I have two models of Many to Many.
Site / Banner
So there is banner_site pivot table.
Banner model has banner_type.
So I want get site with banners which is filtered by banner_type
But this is not working. It does not filter and get s all banners.
What is wrong with this and how can I filter ?
$site = Site::query()
->with(['banners'=> function($query) {
$query->where('banner_type', $this->banner_type);
}])
->find( $site_id );
Please or to participate in this conversation.