baum
baum copied to clipboard
Call to undefined method Baum\Extensions\Query\Builder::defaultOrder()
When I try to do this i get this error
public function getCategories() {
$tree = [];
$tree = Category::defaultOrder()->get()->toHeirarchy();
return response()->json($tree, 200, ['Content-Length' => strlen(json_encode($tree))]);
}
to work around this i have to do this
foreach (Category::roots()->orderBy('lft', 'asc')->get() as $root) { $tree[] = $root->getDescendantsAndSelf()->toHierarchy(); }