@SaeedPrez I'm using nested sets, but the part I'm struggling with are relations at each level i.e.
I can get all descendants and maintain relationship integrity with the getPage() example below. However, what I'm unable to solve with nested sets is dynamically loading other relations e.g. menu, document, image, etc. at each level. If I attempt a ->with() or a ->load() it will do so at level one which means I have to lazy load these relations through some recursive method at every depth.
This will return all sections with child sections for n depth:
public function getPage()
{
$getPage = $this->page
->where('slug', $this->pageSlug)
->with(['theme','layout.sections'])
->first();
foreach ($getPage->layout->sections as $section) {
$section->setRelation('children', $section->getDescendants()->toHierarchy()) ;
}
return view('company.main')->with('page', $getPage);
}
what I'm looking for is a something like the pseudo example below. Where it will recursively get all nested sets with relations for every section found.
$section->setRelation('children', $section->getDescendants()->toHierarchy())->with(['images','documents', 'menus']) ;