mirror of
https://github.com/Oreolek/yii2-nested-sets.git
synced 2024-07-01 05:55:00 +03:00
73 lines
1.3 KiB
PHP
73 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* @link https://github.com/creocoder/yii2-nested-sets-behavior
|
|
* @copyright Copyright (c) 2015 Alexander Kochetov
|
|
* @license http://opensource.org/licenses/BSD-3-Clause
|
|
*/
|
|
|
|
namespace tests\models;
|
|
|
|
use creocoder\nestedsets\NestedSetsBehavior;
|
|
|
|
/**
|
|
* MultipleRootsTree
|
|
*
|
|
* @property integer $id
|
|
* @property integer $tree
|
|
* @property integer $lft
|
|
* @property integer $rgt
|
|
* @property integer $depth
|
|
* @property string $name
|
|
*/
|
|
class MultipleRootsTree extends \yii\db\ActiveRecord
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'multiple_roots_tree';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => NestedSetsBehavior::className(),
|
|
'treeAttribute' => 'tree',
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
['name', 'required'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function transactions()
|
|
{
|
|
return [
|
|
self::SCENARIO_DEFAULT => self::OP_ALL,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function find()
|
|
{
|
|
return new MultipleRootsTreeQuery(get_called_class());
|
|
}
|
|
}
|