I have 2 tables Articles and Revisions
There is a relationship between them one2many
The Revisions table has 2 columns isApproved and isPublished
Now, I want to select all articles, when its first Approved revision is Published
Article::whereHas('revisions', function ($query) {
$query->where('isApproved', 1)->where('isPublished', 1);
});
But this code selected all articles that have approved and published revisions