1. Go to this page and download the library: Download paulzi/yii2-auto-tree library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paulzi / yii2-auto-tree example snippets
use paulzi\adjacencylist\AdjacencyListBehavior;
use paulzi\nestedsets\NestedSetsBehavior;
use paulzi\autotree\AutoTreeTrait;
class Sample extends \yii\db\ActiveRecord
{
use AutoTreeTrait;
public function behaviors() {
return [
['class' => AdjacencyListBehavior::className()],
['class' => NestedSetsBehavior::className()],
];
}
}
use paulzi\autotree\AutoTreeTrait;
class Sample extends \yii\db\ActiveRecord
{
use AutoTreeTrait;
/**
* @param int|null $depth
* @return \yii\db\ActiveQuery
*/
public function getParents($depth = null)
{
return $this->autoTreeCall('getParents', ['al', 'mp', 'ns', 'ni'], [$depth]);
}
}
use paulzi\autotree\AutoTreeTrait;
class Sample extends \yii\db\ActiveRecord
{
use AutoTreeTrait;
/**
* @return array
*/
private static function autoTreeAliases()
{
return [
'example\adjacencylist\AdjacencyListBehavior' => 'al',
'example\nestedsets\NestedSetsBehavior' => 'ns',
'example\nestedintervals\NestedIntervalsBehavior' => 'ni',
'example\materializedpath\MaterializedPathBehavior' => 'mp',
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.