Latest

Thursday, July 6, 2017

Need to include a variable in a function of a query in Laravel

Asked by: prgrm


I have something like this:

$configurations = Configs:all();

foreach($configs as $config){

$documents = document::whereHas('user', function ($q) {
$q->where("portal_id", $config->id),})->get()

...
}

This does not work because $config is not defined in the query function.

How do I put the $config->id object there?



Source

No comments:

Post a Comment

Adbox