creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

Configure query class as follows? #54

Closed gb5256 closed 9 years ago

gb5256 commented 9 years ago

Hello, I am just switching to yii2 from yii1, so it might be that I have a general problem of understanding. You write "Configure query class as follows". But I do not have a query class. I am using the advanced yii2 template. Can you give me a hint where that has to be put? Thanks, gb5256

Mihai-P commented 9 years ago

So you should create a class like this https://github.com/Mihai-P/yii2-core/blob/master/components/NestedQuery.php

And in the actual model you should declare something like this https://github.com/Mihai-P/yii2-core/blob/master/models/Menu.php see the behaviors, transactions and find functions.

The NestedQuery allows you operations like

$leaves = Menu::find()->leaves()->all();
$children = $countries->children()->all();
gb5256 commented 9 years ago

Thanks for this. The missing point was where to put it and to use use core\components\NestedQuery; inside the model.

PS: I am a very happy user of your yii1 nested set (and now also of this one as it seems...) Thanks again, gb5256