|
|
@ -83,12 +83,21 @@ class m150722_150100_multiple_tree extends Migration |
|
|
|
```php |
|
|
|
```php |
|
|
|
use paulzi\nestedsets\NestedSetsBehavior; |
|
|
|
use paulzi\nestedsets\NestedSetsBehavior; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @property integer $id |
|
|
|
|
|
|
|
* @property integer $lft |
|
|
|
|
|
|
|
* @property integer $rgt |
|
|
|
|
|
|
|
* @property integer $depth |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @mixin NestedSetsBehavior |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
class Sample extends \yii\db\ActiveRecord |
|
|
|
class Sample extends \yii\db\ActiveRecord |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function behaviors() { |
|
|
|
public function behaviors() { |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
[ |
|
|
|
[ |
|
|
|
'class' => NestedSetsBehavior::className(), |
|
|
|
'class' => NestedSetsBehavior::class, |
|
|
|
// 'treeAttribute' => 'tree', |
|
|
|
// 'treeAttribute' => 'tree', |
|
|
|
], |
|
|
|
], |
|
|
|
]; |
|
|
|
]; |
|
|
@ -291,4 +300,4 @@ To delete a node with descendants: |
|
|
|
$node11 = Sample::findOne(['name' => 'node 1.1']); |
|
|
|
$node11 = Sample::findOne(['name' => 'node 1.1']); |
|
|
|
$node11->delete(); // delete node, children come up to the parent |
|
|
|
$node11->delete(); // delete node, children come up to the parent |
|
|
|
$node11->deleteWithChildren(); // delete node and all descendants |
|
|
|
$node11->deleteWithChildren(); // delete node and all descendants |
|
|
|
``` |
|
|
|
``` |
|
|
|