Double nested RESTful api view

Hi,

Using ?expand=relationName I can enfroce a RESTfull api view to contain related model data.

But how to ensure related models of this related model to be nested in the second trier?

I need:

USER -> ORDERS -> ORDER’s ITEMS

in a single (nested) view!

Thanks ahead of your kind feedback!

I am sure you can use expand=relationName.subRelation but i am not sure if you have to preload the given relation with with().

for example:

return new ActiveDataProvider([
    'query' => User::find()->with(['orders.orderItems']),
]);

So you might try also just ['orders'] without the sub relation.

1 Like

Sweet - thank you so much !!!