PHP code example of rysonliu / laravel-tree
1. Go to this page and download the library: Download rysonliu/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/ */
rysonliu / laravel-tree example snippets
[
[
'id' => 1,
'parent_id' => 0,
'label' => 'Dashboard',
'link' => '/dashboard',
'icon' => null,
'roles' => 'Admin,',
'sub_menus' => [
[
'id' => 2,
'parent_id' => 1,
'label' => 'Fiance',
'link' => '/dashboard/finace',
'icon' => null,
'roles' => 'Admin,Fiance'
],
[
'id' => 3,
'parent_id' => 1,
'label' => 'Operation',
'link' => '/dashboard/operation',
'icon' => null,
'roles' => 'Admin,Operation'
]
]
]
];
use Betterde\Tree\Generator;
$menus = [
[
'id' => 1,
'parent_id' => 0,
'label' => 'Dashboard',
'link' => '/dashboard',
'icon' => null,
'roles' => 'Admin,'
],
[
'id' => 2,
'parent_id' => 1,
'label' => 'Fiance',
'link' => '/dashboard/finace',
'icon' => null,
'roles' => 'Admin,Fiance'
],
[
'id' => 3,
'parent_id' => 1,
'label' => 'Operation',
'link' => '/dashboard/operation',
'icon' => null,
'roles' => 'Admin,Operation'
],
];
$generator = new Generator();
$tree = $generator->make($menus, 'id', 'parent_id', 'sub_menus', 0);