Skip to content

[Feature request] insert at position #4

@pepijnolivier

Description

@pepijnolivier

Currently we can already make a node a child of another node as such:

// Directly with a relation
$child1 = $root->children()->create(['name' => 'Child 1']);

// with the `makeChildOf` method
$child2 = Category::create(['name' => 'Child 2']);
$child2->makeChildOf($root);

It would be nice if we could call something like createAtPosition / makeChildAtPosition.
This way we can insert new nodes at the right place without needing to have knowledge about the siblings.

The package should then detect and move all existing nodes (+1 starting from the position)

For example:

Add node as the first child of its parent
$root->children()->createAtPosition(0, ['name' => 'Child 1']);

Add node as the third child of its parent
$root->children()->createAtPosition(2, ['name' => 'Child 3']);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions