etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

Call to undefined method Baum\Extensions\Query\Builder::defaultOrder() #258

Open kirkdm opened 7 years ago

kirkdm commented 7 years ago

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(); }