Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTree()'s root elements are unordered #1

Closed
mikebridge opened this issue Jan 5, 2024 · 1 comment
Closed

getTree()'s root elements are unordered #1

mikebridge opened this issue Jan 5, 2024 · 1 comment

Comments

@mikebridge
Copy link

mikebridge commented Jan 5, 2024

I'm not sure if this is expected behaviour, but I have an ordered closure table that uses the BelongsToOrderedTree trait, and I notice that the root elements of getTree are not ordered. The children are ordered however.

According to the documentation, The children relation will ... be ordered. ---so maybe it doesn't apply to the root elements?

For example:

TestNode::getTree()
[
	{
		"id": 1,
		"parent_id": null,
		"name": "Test Node #1",
		"organization_id": 1,
		"order": 3,
		"deleted_at": null,
		"created_at": "2024-01-04T19:52:10+0000",
		"updated_at": "2024-01-05T20:44:25+0000",
		"resource_urn": "test-node.1",
		"children": [
			{
				"id": 4,
				"parent_id": 1,
				"name": "Test Node #4",
				"organization_id": 1,
				"order": 1,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:19+0000",
				"updated_at": "2024-01-05T20:44:34+0000",
				"resource_urn": "test-node.4",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 4,
					"depth": 1
				},
				"children": []
			},
			{
				"id": 3,
				"parent_id": 1,
				"name": "Test Node #3",
				"organization_id": 1,
				"order": 2,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:16+0000",
				"updated_at": "2024-01-05T20:44:38+0000",
				"resource_urn": "test-node.3",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 3,
					"depth": 1
				},
				"children": []
			},
			{
				"id": 5,
				"parent_id": 1,
				"name": "Test Node #5",
				"organization_id": 1,
				"order": 3,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:21+0000",
				"updated_at": "2024-01-05T20:44:38+0000",
				"resource_urn": "test-node.5",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 5,
					"depth": 1
				},
				"children": []
			}
		],
		"descendants": [
			{
				"id": 3,
				"parent_id": 1,
				"name": "Test Node #3",
				"organization_id": 1,
				"order": 2,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:16+0000",
				"updated_at": "2024-01-05T20:44:38+0000",
				"resource_urn": "test-node.3",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 3,
					"depth": 1
				},
				"children": []
			},
			{
				"id": 4,
				"parent_id": 1,
				"name": "Test Node #4",
				"organization_id": 1,
				"order": 1,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:19+0000",
				"updated_at": "2024-01-05T20:44:34+0000",
				"resource_urn": "test-node.4",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 4,
					"depth": 1
				},
				"children": []
			},
			{
				"id": 5,
				"parent_id": 1,
				"name": "Test Node #5",
				"organization_id": 1,
				"order": 3,
				"deleted_at": null,
				"created_at": "2024-01-04T19:52:21+0000",
				"updated_at": "2024-01-05T20:44:38+0000",
				"resource_urn": "test-node.5",
				"closure": {
					"ancestor_id": 1,
					"descendant_id": 5,
					"depth": 1
				},
				"children": []
			}
		]
	},
	{
		"id": 2,
		"parent_id": null,
		"name": "Test Node #2",
		"organization_id": 1,
		"order": 1,
		"deleted_at": null,
		"created_at": "2024-01-04T19:52:14+0000",
		"updated_at": "2024-01-05T20:44:23+0000",
		"resource_urn": "test-node.2",
		"children": [],
		"descendants": []
	},
	{
		"id": 6,
		"parent_id": null,
		"name": "Test Node #6",
		"organization_id": 1,
		"order": 2,
		"deleted_at": null,
		"created_at": "2024-01-04T19:52:23+0000",
		"updated_at": "2024-01-05T20:44:25+0000",
		"resource_urn": "test-node.6",
		"children": [],
		"descendants": []
	}
]
@michaelbaril
Copy link
Owner

Hi @mikebridge , thanks for your feedback and sorry for the late answer. You're right, they should be ordered, I guess I just didn't think of it :)

Fixed in v3.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants