1. Go to this page and download the library: Download codrasil/closurable 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/ */
$child = MyModel::find(2);
$siblings = $child->siblings(); // or $child->siblings
$firstChild = MyModel::find(2);
$secondChild = $firstChild->next(); // or $firstChild->next
$secondChild = MyModel::find(3);
$firstChild = $secondChild->previous(); // or $secondChild->previous
$child = MyModel::find(2);
$parent = $child->parent(); // or $child->parent
$user = User::find(1);
$child = MyModel::find(4);
$ancestors = $child->ancestors();
// will output the parent([of the parent]*n) + the child.
// dd($ancestors) to inspect actual data.
$parent = MyModel::find(2);
$descendants = $parent->descendants();
// will output the children([of the children]*n) + the parent.
// dd($descendants) to inspect actual data.