I using https://github.com/creocoder/yii2-nested-sets extension for Yii2!
So, first version for Yii1 was good but in this version i have some problem.
All done strictly according to the manual!
When created all models i earn error:
This error appear at any query to Category table. If delete behavior entire work ;(
Categories Model:
<?php
namespace backend\models;
use creocoder\nestedsets\NestedSetsBehavior;
use yii\db\ActiveRecord;
class Categories extends ActiveRecord
{
public function behaviors() {
return [
'tree' => [
'class' => NestedSetsBehavior::className(),
'treeAttribute' => 'tree',
],
];
}
public function transactions()
{
return [
self::SCENARIO_DEFAULT => self::OP_ALL,
];
}
public static function find()
{
return new CategoryQuery(get_called_class());
}
}
CategoryQuery Model:
<?php
namespace backend\models;
use creocoder\nestedsets\NestedSetsQueryBehavior;
use yii\db\ActiveRecord;
class CategoryQuery extends ActiveRecord
{
public function behaviors() {
return [
NestedSetsQueryBehavior::className(),
];
}
}