Comments (8)
Hi!
Use defaultOrder method on query builder to order by lft value.
See: https://github.com/lazychaser/laravel-nestedset#default-order
from laravel-nestedset.
Thanks for the reply, but I can’t see how to get this to work
As I’ve multiple trees in the table, I’ve tried reading the data for just one using a query like
$list = Table::defaultOrder()->where(‘x’, ‘=‘, 1000->get(1) ;
which does return the nodes in the _lft order. However, when I attempt to transform this to a tree using
$list->getDescendants()->toTree()->toArray() ;
or
$list->toTree()->toArray() ;
it fails with undefined methods of getDescendants or toTree.
Am I doing something wrong? Basically, how do I retrieve the complete tree in the actual stored tree order?
And really, since the package is dedicated to supporting nesting, I think it would be sensible to have this action as the default behaviour, without the requirement to apply additional ordering criteria.
Noel Walsh
On 22 Jan 2015, at 04:50, Alexander Kalnoy [email protected] wrote:
Hi!
Use defaultOrder method on query builder to order by lft value.
22 ñÎ× 2015 Ç. 0:10 ÐÏÌØÚÏ×ÁÔÅÌØ "noelwalsh" [email protected]
ÎÁÐÉÓÁÌ:Thanks for the package, it looks perfrect for building a tree view in my
app.That said, when I reorder the nodes, using down() and up(), I can see they
left and right values adjusting, but I can't find any way to read them back
in the new order. Instead, they're always returned in the same order, which
I guess is the original insertion order, even if I call the toTree method.Is there any method provided to do this sorting or is up to me to do it
manually?N
Reply to this email directly or view it on GitHub
#31.—
Reply to this email directly or view it on GitHub #31 (comment).
from laravel-nestedset.
Get descendants is only available for a single node. As for the ordering,
someone would want to order by some other criteria.
22 Янв 2015 г. 16:21 пользователь "noelwalsh" [email protected]
написал:
Thanks for the reply, but I can’t see how to get this to work
As I’ve multiple trees in the table, I’ve tried reading the data for just
one using a query like$list = Table::defaultOrder()->where(‘x’, ‘=‘, 1000->get(1) ;
which does return the nodes in the _lft order. However, when I attempt to
transform this to a tree using$list->getDescendants()->toTree()->toArray() ;
or
$list->toTree()->toArray() ;it fails with undefined methods of getDescendants or toTree.
Am I doing something wrong? Basically, how do I retrieve the complete tree
in the actual stored tree order?And really, since the package is dedicated to supporting nesting, I think
it would be sensible to have this action as the default behaviour, without
the requirement to apply additional ordering criteria.Noel Walsh
Crewe IT
Tel: 07951 183 553On 22 Jan 2015, at 04:50, Alexander Kalnoy [email protected]
wrote:Hi!
Use defaultOrder method on query builder to order by lft value.
22 ñÎ× 2015 Ç. 0:10 ÐÏÌØÚÏ×ÁÔÅÌØ "noelwalsh" [email protected]
ÎÁÐÉÓÁÌ:Thanks for the package, it looks perfrect for building a tree view in
my
app.That said, when I reorder the nodes, using down() and up(), I can see
they
left and right values adjusting, but I can't find any way to read them
back
in the new order. Instead, they're always returned in the same order,
which
I guess is the original insertion order, even if I call the toTree
method.Is there any method provided to do this sorting or is up to me to do
it
manually?N
Reply to this email directly or view it on GitHub
#31.—
Reply to this email directly or view it on GitHub <
https://github.com/lazychaser/laravel-nestedset/issues/31#issuecomment-70971189>.—
Reply to this email directly or view it on GitHub
#31 (comment)
.
from laravel-nestedset.
I’m sure they would, but I do think the obvious default should be the sorted order.
But you didn’t tell me how to access the complete tree in the sorted order. Is it possible please?
Noel Walsh
On 22 Jan 2015, at 15:26, Alexander Kalnoy [email protected] wrote:
Get descendants is only available for a single node. As for the ordering,
someone would want to order by some other criteria.
22 Янв 2015 г. 16:21 пользователь "noelwalsh" [email protected]
написал:Thanks for the reply, but I can’t see how to get this to work
As I’ve multiple trees in the table, I’ve tried reading the data for just
one using a query like$list = Table::defaultOrder()->where(‘x’, ‘=‘, 1000->get(1) ;
which does return the nodes in the _lft order. However, when I attempt to
transform this to a tree using$list->getDescendants()->toTree()->toArray() ;
or
$list->toTree()->toArray() ;it fails with undefined methods of getDescendants or toTree.
Am I doing something wrong? Basically, how do I retrieve the complete tree
in the actual stored tree order?And really, since the package is dedicated to supporting nesting, I think
it would be sensible to have this action as the default behaviour, without
the requirement to apply additional ordering criteria.Noel Walsh
On 22 Jan 2015, at 04:50, Alexander Kalnoy [email protected]
wrote:Hi!
Use defaultOrder method on query builder to order by lft value.
22 ñÎ× 2015 Ç. 0:10 ÐÏÌØÚÏ×ÁÔÅÌØ "noelwalsh" [email protected]
ÎÁÐÉÓÁÌ:Thanks for the package, it looks perfrect for building a tree view in
my
app.That said, when I reorder the nodes, using down() and up(), I can see
they
left and right values adjusting, but I can't find any way to read them
back
in the new order. Instead, they're always returned in the same order,
which
I guess is the original insertion order, even if I call the toTree
method.Is there any method provided to do this sorting or is up to me to do
it
manually?N
Reply to this email directly or view it on GitHub
#31.—
Reply to this email directly or view it on GitHub <
https://github.com/lazychaser/laravel-nestedset/issues/31#issuecomment-70971189>.—
Reply to this email directly or view it on GitHub
#31 (comment)
.—
Reply to this email directly or view it on GitHub #31 (comment).
from laravel-nestedset.
I’m sure they would, but I do think the obvious default should be the sorted order.
This behaviour used to be in previous version and caused many problems, so I decided to make it optional.
But you didn’t tell me how to access the complete tree in the sorted order. Is it possible please?
Table::defaultOrder()->get()->toTree();
from laravel-nestedset.
Thanks you Alexander, after adding a where clause to limit to the particular tree I required, that did the trick
Noel Walsh
On 23 Jan 2015, at 06:46, Alexander Kalnoy [email protected] wrote:
I’m sure they would, but I do think the obvious default should be the sorted order.
This behaviour used to be in previous version and caused many problems, so I decided to make it optional.
But you didn’t tell me how to access the complete tree in the sorted order. Is it possible please?
Table::defaultOrder()->get()->toTree();
—
Reply to this email directly or view it on GitHub #31 (comment).
from laravel-nestedset.
I've pushed a new commit where getDescendands
applies default order by default, so you can do following:
$node = Table::where('x', '=', 1000)->find();
$descendands = $node->getDescendands()->toTree();
from laravel-nestedset.
That’s brilliant Alexander.
Thanks very much for your help
Noel Walsh
On 23 Jan 2015, at 12:54, Alexander Kalnoy [email protected] wrote:
I've pushed a new commit where getDescendands applies default order by default, so you can do following:
$node = Table::where('x', '=', '1000)->find();
$descendands = $node->getDescendands()->toTree();
—
Reply to this email directly or view it on GitHub #31 (comment).
from laravel-nestedset.
Related Issues (20)
- Integrity constraint violation error when deleting a node. HOT 1
- How to Move Between Root
- Use fully qualified key on QueryBuilder
- Problem with deadlock and broken tree when performing new registrations.
- My workaround to rebuildTree().
- My node has no parent, but has ancestors HOT 3
- Laravel 10 support HOT 4
- How to restrict descendants by status? HOT 1
- Efficiently restrict number of levels when using descendants()
- Is it possible to move QueryBuilder logic to trait? To support custom Builders
- You May Ordered Children with adding this method.
- Code runs in SQL error for height = 0 in QueryBuilder::columnPatch(...)
- fix parent function name
- Binary Tree Function
- finding siblings and parents
- Parent _lft and _rgt not updated after adding child using `create()` method HOT 2
- Sibling of the same category will be move as per id or record list. HOT 1
- Undefined method `append`
- Laravel 11 HOT 1
- Problem to require in Laravel 11 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-nestedset.