You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Here you can see my ancestor and descendant table, Ancestor | Descendant
Electronics | Computer
Electronics | Laptop
Electronics | Mobile phone
Here is my code,
$page = Page::find(1);
$descendants = $page->getDescendants();
$descendants = $page->getDescendantsWhere('real_depth', '=', 1);
foreach ($descendants as $value) {
$ancestor=$page->getAncestors();
echo $ancestor[0]->name
echo $value->name;
}
}
Question:
As of right now, this works fine, but there will be a lot of queries if I handle some large amount of data, so is there any way to get the descendant of the ancestor with a descendant from a single query?
Thanks
The text was updated successfully, but these errors were encountered:
Hello,
Here you can see my ancestor and descendant table,
Ancestor | Descendant
Electronics | Computer
Electronics | Laptop
Electronics | Mobile phone
Here is my code,
$page = Page::find(1);
$descendants = $page->getDescendants();
$descendants = $page->getDescendantsWhere('real_depth', '=', 1);
foreach ($descendants as $value) {
$ancestor=$page->getAncestors();
echo $ancestor[0]->name
echo $value->name;
}
}
Question:
As of right now, this works fine, but there will be a lot of queries if I handle some large amount of data, so is there any way to get the descendant of the ancestor with a descendant from a single query?
Thanks
The text was updated successfully, but these errors were encountered: