getValid($user_id); $output = []; foreach ($menus as $menu) { $output []= $this->buildItem($menu); } return implode(PHP_EOL, $output); } protected function buildItem(mixed $item): string { if (isset($item->submenus)) { return $this->buildDropdown($item); } return "urls->base}}/{{$item->url}}\">{{$item->title}}"; } protected function buildDropdown(mixed $item): string { $output []= '