php - How to Constraining Eager Loads With whereIn function Laravel -


how pass controls function

$controls = $project['records']->pluck('id');     $domain = processdomain::with(['         process.subprocess.control' =>         function ($query,$controls) {             $query->wherein ('id', $controls);         } ])->get(); 

if using anonymous function can pass variable this:

$message = 'hello'; // inherit $message $example = function () use ($message) {     var_dump($message); }; $example(); 

in case can try:

$controls = $project['records']->pluck('id'); $domain = processdomain::with(['process.subprocess.control' => function ($query) use ($controls) {         $query->wherein ('id', $controls);     }])->get(); 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -