Giter VIP home page Giter VIP logo

Comments (8)

lazychaser avatar lazychaser commented on June 18, 2024

Hi!

Use defaultOrder method on query builder to order by lft value.

See: https://github.com/lazychaser/laravel-nestedset#default-order

from laravel-nestedset.

noelwalsh avatar noelwalsh commented on June 18, 2024

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.

lazychaser avatar lazychaser commented on June 18, 2024

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 553

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)
.

from laravel-nestedset.

noelwalsh avatar noelwalsh commented on June 18, 2024

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.

lazychaser avatar lazychaser commented on June 18, 2024

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.

noelwalsh avatar noelwalsh commented on June 18, 2024

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.

lazychaser avatar lazychaser commented on June 18, 2024

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.

noelwalsh avatar noelwalsh commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.