I am working on a SilverStripe project. Now I am querying the data. What I am trying to do is getting all the records running where clause on the count of its relations.
The below query will get all the NewsPage records. NewsPage has many blogs. So, they have a one-to-many relationship:
NewsPage::get();
So if I want to get all the blogs on the news page, I have to do this:
$newPage->BlogPosts()
Now, what I am trying to do is that I am trying to get all the news pages that have more than one blog post:
Something like this arbitrary code
$newPage->where('BlogPosts.Count', '>', 1)->get();
How can I achieve this?