Answer the question
In order to leave comments, you need to log in
How to get in dataProvider all products of all orders in one list in Yii2?
Good afternoon.
It means - I'm a buyer, I have orders. There are items in the orders. I want to get all the goods of all orders in one list in one dataProvider at once.
Naturally, the models exhibited relationships with each other.
Please tell me how can this be done?
Answer the question
In order to leave comments, you need to log in
Naturally, the models exhibited relationships with each other.
$user_id = 167;
$query = Product::find()->joinWith(['order.user'=>function($query) use ($user_id) {
return $query->where(['user.id'=>$user_id]);
}]);
$dataProvider = new ActiveDataProvider([
'query' => $query
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question