| 1 | <?php |
||
| 20 | class NestedSetsQueryBehavior extends Behavior |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Gets the root nodes. |
||
| 24 | * @return \yii\db\ActiveQuery the owner |
||
| 25 | */ |
||
| 26 | public function roots() |
||
| 27 | 6 | { |
|
| 28 | $model = new $this->owner->modelClass(); |
||
| 29 | 6 | ||
| 30 | $this->owner |
||
| 31 | 6 | ->andWhere([$model->leftAttribute => 1]) |
|
| 32 | 6 | ->addOrderBy([$model->primaryKey()[0] => SORT_ASC]); |
|
| 33 | 6 | ||
| 34 | return $this->owner; |
||
| 35 | 6 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Gets the leaf nodes. |
||
| 39 | 6 | * @return \yii\db\ActiveQuery the owner |
|
| 40 | */ |
||
| 41 | public function leaves() |
||
| 58 | } |
||
| 59 |