【发布时间】:2014-10-11 17:44:09
【问题描述】:
在 Yii1 中我可以这样做:
$posts=Post::model()->with(array(
'comments'=>array(
'scopes'=>array('recently','approved')
),
))->findAll();
有没有办法在 Yii2 的 with() 的回调函数中调用一个关系的范围?
Customer::find()->with([
'orders' => function ($query) {
$query->andWhere('status = 1');
},
'country',
])->all();
【问题讨论】:
标签: php activerecord scope yii2