public static function buildRecursiveName(\App\Model\Category $item = null, $path = "") { if (!$item || !$item->loaded() || !$item->id()) { return $path; } $parts = [$path]; $newPart = $item->name; if (strtoupper($newPart) == '0_ROOT') { $newPart = ""; } array_unshift($parts, $newPart); $parts = array_filter($parts); $path = implode(' / ', $parts); $path = self::buildRecursiveName($item->parentCategory, $path); return $path; }