Hi there,
is there a way to add parameters to the anonymous function used in with() or joinWith() relations ?
For example, in the documentation we have :
// SELECT `customer`.* FROM `customer`
// LEFT JOIN `order` ON `order`.`customer_id` = `customer`.`id` AND `order`.`status` = 1
//
// SELECT * FROM `order` WHERE `customer_id` IN (...)
$customers = Customer::find()->joinWith([
'orders' => function ($query) {
$query->onCondition(['order.status' => Order::STATUS_ACTIVE]);
},
])->all();
What if i want to get all orders with amount = 50 ?
$amount = 50;
$customers = Customer::find()->joinWith([
'orders' => function ($query) {
$query->onCondition(['order.amount' => $amount]);
},
])->all();
In the anonymous function, $amount is obviously undefined, is there a way to solve that ?
Thanks !