Skip to content

Instantly share code, notes, and snippets.

@chungnt92
chungnt92 / traversing-example.md
Created December 20, 2017 05:24 — forked from etrepat/traversing-example.md
Traversing the Hierarchy Tree with Baum - An Example

The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.

<?php

$root = Category::roots()->with('children')->first();

echo "<h3>{$root->name}</h3>";

foreach($root->children as $category) {