I think the method you're looking for is whereHas
(under the heading "Querying Relationship Existence").
$questions = \App\ContentLegacy::with('staff', 'meta', 'questionStandards')
->where('post_type','nm_question')
->whereHas('meta', function ($query) {
$query->where('meta_key', 'flagged');
})
->orderBy("post_date", "DES")
->paginate(20);
The has
method can take a callback argument too, but in this case that would be more verbose.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community