Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bremmurd's avatar

Laravel Query Builder Issues

Hello. What's wrong with this query? I can't seem to get it return the correct value

$offerwall = OfferWall::find($offerwall)->with(['offer'=> function($query) use ($proxy_results) {
                $query->where('status', 'active')->whereHas('targeting', function($query) use ($proxy_results) {
                    $query->where('targeting_details.countries_allowed','like', "%\"{$proxy_results['154.159.237.197']['country']}\"%");
                });
            }])->get();
0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Replace with() with load() or move it before find(). And remove ->get() at the end

1 like

Please or to participate in this conversation.