In below query the awarded
, banned
, featured
and published
parts are being ignored, why?
Query: Show me a list of all featured published books with an author that has been awarded and has not been banned.
$books = myBooks::with('authors')
->whereHas('authors', function ($query) {
$query
->where([
'awarded' => true,
'banned' => false
]);
})
->where([
'featured' => true,
'published' => true
])
->latest()
->get();
2
Answers
Most likely some of these fields:
awarded
,banned
,featured
andpublished
are present in both of your tables. For the query to work correctly in the conditions you need to specify the ownership of these fieldsI don’t see the syntax you are using documented anywhere. You can try doing: