如何将控件传递给函数
$controls = $project['records']->pluck('id');
$domain = ProcessDomain::with(['
process.subprocess.control' =>
function ($query,$controls) {
$query->whereIn ('id', $controls);
}
])->get();
答案 0 :(得分:0)
如果您使用的是匿名函数,则可以像这样传递变量:
$message = 'Hello';
// Inherit $message
$example = function () use ($message) {
var_dump($message);
};
$example();
在您的情况下,您可以尝试:
$controls = $project['records']->pluck('id');
$domain = ProcessDomain::with(['process.subprocess.control' => function ($query) use ($controls) {
$query->whereIn ('id', $controls);
}])->get();