Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

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.

0

That's great, it works.

Thanks so much !!!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.