You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					72 lines
				
				1.4 KiB
			
		
		
			
		
	
	
					72 lines
				
				1.4 KiB
			| 
								 
											10 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @link https://github.com/paulzi/yii2-nested-sets
							 | 
						||
| 
								 | 
							
								 * @copyright Copyright (c) 2015 PaulZi <pavel.zimakoff@gmail.com>
							 | 
						||
| 
								 | 
							
								 * @license MIT (https://github.com/paulzi/yii2-nested-sets/blob/master/LICENSE)
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace paulzi\nestedsets\tests\models;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use paulzi\nestedsets\NestedSetsBehavior;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @author PaulZi <pavel.zimakoff@gmail.com>
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @property integer $id
							 | 
						||
| 
								 | 
							
								 * @property integer $lft
							 | 
						||
| 
								 | 
							
								 * @property integer $rgt
							 | 
						||
| 
								 | 
							
								 * @property integer $depth
							 | 
						||
| 
								 | 
							
								 * @property string $slug
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @property Node[] $parents
							 | 
						||
| 
								 | 
							
								 * @property Node $parent
							 | 
						||
| 
								 | 
							
								 * @property Node $root
							 | 
						||
| 
								 | 
							
								 * @property Node[] $descendants
							 | 
						||
| 
								 | 
							
								 * @property Node[] $children
							 | 
						||
| 
								 | 
							
								 * @property Node[] $leaves
							 | 
						||
| 
								 | 
							
								 * @property Node $prev
							 | 
						||
| 
								 | 
							
								 * @property Node $next
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @method static Node|null findOne() findOne($condition)
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @mixin NestedSetsBehavior
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Node extends \yii\db\ActiveRecord
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @inheritdoc
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public static function tableName()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return '{{%tree}}';
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @inheritdoc
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function behaviors()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return [
							 | 
						||
| 
								 | 
							
								            [
							 | 
						||
| 
								 | 
							
								                'class' => NestedSetsBehavior::className(),
							 | 
						||
| 
								 | 
							
								            ],
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @inheritdoc
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function transactions()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return [
							 | 
						||
| 
								 | 
							
								            self::SCENARIO_DEFAULT => self::OP_ALL,
							 | 
						||
| 
								 | 
							
								        ];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @return NodeQuery
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public static function find()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return new NodeQuery(get_called_class());
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |