PHP code example of laraditz / laravel-tree
1. Go to this page and download the library: Download laraditz/laravel-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/ */
laraditz / laravel-tree example snippets
php
Schema::create('trees', function (Blueprint $table) {
...
$table->addLaravelTreeColumns();
...
});
php
Tree::create([
'user_id' => 1
])->asRoot()
php
// $tree is the parent object
Tree::create([
'user_id' => 2
])->asChildOf($tree);
// or
$tree->appendChild([
'user_id' => 2
]);