PHP code example of gilek / yii2-gtreetable
1. Go to this page and download the library: Download gilek/yii2-gtreetable 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/ */
gilek / yii2-gtreetable example snippets
[
'nodeCreate' => [
'class' => 'gilek\gtreetable\actions\NodeCreateAction',
'treeModelName' => Tree::className(),
'beforeRun' => function() {
if (!Yii::$app->user->can('Node create')) {
throw new \yii\web\ForbiddenHttpException();
}
}
]
php
class Tree extends \gilek\gtreetable\models\TreeModel
{
public static function tableName()
{
return 'tree';
}
}
php
use app\models\Tree;
class TreeController extends \yii\web\Controller
{
public function actions() {
return [
'nodeChildren' => [
'class' => 'gilek\gtreetable\actions\NodeChildrenAction',
'treeModelName' => Tree::className()
],
'nodeCreate' => [
'class' => 'gilek\gtreetable\actions\NodeCreateAction',
'treeModelName' => Tree::className()
],
'nodeUpdate' => [
'class' => 'gilek\gtreetable\actions\NodeUpdateAction',
'treeModelName' => Tree::className()
],
'nodeDelete' => [
'class' => 'gilek\gtreetable\actions\NodeDeleteAction',
'treeModelName' => Tree::className()
],
'nodeMove' => [
'class' => 'gilek\gtreetable\actions\NodeMoveAction',
'treeModelName' => Tree::className()
],
];
}
public function actionIndex() {
return $this->render('@gilek/gtreetable/views/widget', ['options'=>[
// 'manyroots' => true
// 'draggable' => true
]]);
}
}
php
[
'nodeChildren' => 'controllerA/source',
'nodeCreate' => 'controllerB/create',
'nodeUpdate' => 'controllerC/update',
'nodeDelete' => 'controllerD/delete',
'nodeMove' => 'controllerE/move'
]