In Yii1, I could do something like this:
$posts=Post::model()->with(array( 'comments'=>array( 'scopes'=>array('recently','approved') ), ))->findAll();
Is there a way to call the scope of a relation in the with () callback function in Yii2?
Customer::find()->with([ 'orders' => function ($query) { $query->andWhere('status = 1'); }, 'country', ])->all();
source share