HasNode
trait HasNode
Properties
| protected array | $pending | Pending operations. |
|
| protected bool | $moved | Whether the node has moved since last save. |
|
| static protected bool|null | $hasSoftDelete | Whether the node has soft delete. |
|
| int | $parent_id | ||
| ?static | $parent |
Methods
Bootstrap node events.
Set an action.
Call pending action.
No description
No description
Make a root node.
Get the lower bound.
Append or prepend a node to the parent.
Refresh node's crucial attributes.
Get query for descendants of the node.
Get query for siblings of the node.
Get the node siblings and the node itself.
Get query for the node siblings and the node itself.
Get query for siblings after the node.
Get query for siblings before the node.
Get query for nodes after current node.
Get query for nodes before current node in reversed order.
Get query ancestors of the node.
Save node as root.
Move node up given amount of positions.
Move node down given amount of positions.
Insert node at specific position.
Move a node to the new position.
Insert new node at specified position.
Update the tree when the node is removed physically.
Restore the descendants.
Get a new base query that includes deleted nodes.
No description
No description
No description
No description
No description
Get node height (rgt - lft + 1).
Get number of descendant nodes.
Set the value of model's parent id key.
Get whether node is root.
No description
Get the lft key name.
Get the rgt key name.
Get the parent id key name.
Get the value of the model's lft key.
Get the value of the model's rgt key.
Get the value of the model's parent id key.
Returns node that is next to current node without constraining to siblings.
Returns node that is before current node without constraining to siblings.
No description
No description
No description
No description
No description
No description
No description
Get whether the node is an ancestor of other node, including immediate parent.
Get whether the node is itself or an ancestor of other node, including immediate parent.
Get whether the node has moved since last save.
No description
Get whether user is intended to delete the model from database entirely.
No description
No description
No description
Details
at line 47
QueryBuilder
newEloquentBuilder(Builder $query)
Create a new Eloquent query builder for the model.
at line 55
static void
bootHasNode()
Bootstrap node events.
at line 76
protected HasNode
setNodeAction(string $action, mixed ...$args)
Set an action.
at line 86
protected void
callPendingActions()
Call pending action.
at line 106
static bool
usesSoftDelete()
No description
at line 119
protected bool
actionRaw()
No description
at line 127
protected bool
actionRoot()
Make a root node.
at line 145
protected int
getLowerBound()
Get the lower bound.
at line 153
protected bool
actionAppendOrPrepend(HasNode $parent, bool $prepend = false)
Append or prepend a node to the parent.
at line 181
protected bool
actionBeforeOrAfter(HasNode $node, bool $after = false)
Insert node before or after another node.
at line 191
void
refreshNode()
Refresh node's crucial attributes.
at line 205
BelongsTo
parent()
Relation to the parent.
at line 214
HasMany
children()
Relation to children.
at line 223
DescendantsRelation
descendants()
Get query for descendants of the node.
at line 231
QueryBuilder
siblings()
Get query for siblings of the node.
at line 241
QueryBuilder
siblingsAndSelf()
Get the node siblings and the node itself.
at line 252
Collection
getSiblingsAndSelf(array $columns = ['*'])
Get query for the node siblings and the node itself.
at line 260
QueryBuilder
nextSiblings()
Get query for siblings after the node.
at line 269
QueryBuilder
prevSiblings()
Get query for siblings before the node.
at line 278
QueryBuilder
nextNodes()
Get query for nodes after current node.
at line 287
QueryBuilder
prevNodes()
Get query for nodes before current node in reversed order.
at line 296
AncestorsRelation
ancestors()
Get query ancestors of the node.
at line 304
HasNode
makeRoot()
Make this node a root node.
at line 314
bool
saveAsRoot()
Save node as root.
at line 326
bool
appendNode(HasNode $node)
Append and save a node.
at line 334
bool
prependNode(HasNode $node)
Prepend and save a node.
at line 400
bool
insertAfterNode(HasNode $node)
Insert self after a node and save.
at line 408
bool
insertBeforeNode(HasNode $node)
Insert self before a node and save.
at line 420
HasNode
rawNode(mixed $lft, mixed $rgt, mixed $parentId)
No description
at line 430
bool
up(int $amount = 1)
Move node up given amount of positions.
at line 447
bool
down(int $amount = 1)
Move node down given amount of positions.
at line 464
protected bool
insertAt(int $position)
Insert node at specific position.
at line 476
protected bool
moveNode(int $position)
Move a node to the new position.
at line 491
protected bool
insertNode(int $position)
Insert new node at specified position.
at line 506
protected void
deleteDescendants()
Update the tree when the node is removed physically.
at line 532
protected void
restoreDescendants(CarbonInterface|string $deletedAt)
Restore the descendants.
at line 544
QueryBuilder
newModelBuilder(Builder $query)
Create a new Model query builder for the model.
at line 552
mixed
newNestedSetQuery(string|null $table = null)
Get a new base query that includes deleted nodes.
at line 561
mixed
newScopedQuery(string|null $table = null)
No description
at line 566
mixed
applyNestedSetScope(mixed $query, string|null $table = null)
No description
at line 587
protected array
getScopeAttributes()
No description
at line 592
static mixed
scoped(array $attributes)
No description
at line 604
Collection
newCollection(array $models = [])
No description
at line 612
static HasNode|null
create(array $attributes = [], HasNode|null $parent = null)
Use children key on $attributes to create child nodes.
at line 640
int
getNodeHeight()
Get node height (rgt - lft + 1).
at line 652
int
getDescendantCount()
Get number of descendant nodes.
at line 663
void
setParentIdAttribute(int|null $value)
Set the value of model's parent id key.
Behind the scenes node is appended to found parent node.
at line 679
bool
isRoot()
Get whether node is root.
at line 684
bool
isLeaf()
No description
at line 692
string
getLftName()
Get the lft key name.
at line 700
string
getRgtName()
Get the rgt key name.
at line 708
string
getParentIdName()
Get the parent id key name.
at line 716
int|null
getLft()
Get the value of the model's lft key.
at line 726
int|null
getRgt()
Get the value of the model's rgt key.
at line 736
int|null
getParentId()
Get the value of the model's parent id key.
at line 747
mixed
getNextNode(array $columns = ['*'])
Returns node that is next to current node without constraining to siblings.
This can be either a next sibling or a next sibling of the parent node.
at line 758
mixed
getPrevNode(array $columns = ['*'])
Returns node that is before current node without constraining to siblings.
This can be either a prev sibling or parent node.
at line 766
Collection
getAncestors(array $columns = ['*'])
No description
at line 774
Collection
getDescendants(array $columns = ['*'])
No description
at line 782
Collection
getSiblings(array $columns = ['*'])
No description
at line 790
Collection
getNextSiblings(array $columns = ['*'])
No description
at line 798
Collection
getPrevSiblings(array $columns = ['*'])
No description
at line 806
mixed
getNextSibling(array $columns = ['*'])
No description
at line 814
mixed
getPrevSibling(array $columns = ['*'])
No description
at line 822
bool
isDescendantOf(HasNode $other)
Get whether a node is a descendant of other node.
at line 832
bool
isSelfOrDescendantOf(HasNode $other)
Get whether a node is itself or a descendant of other node.
at line 841
bool
isChildOf(HasNode $other)
Get whether the node is immediate children of other node.
at line 849
bool
isSiblingOf(HasNode $other)
Get whether the node is a sibling of another node.
at line 857
bool
isAncestorOf(HasNode $other)
Get whether the node is an ancestor of other node, including immediate parent.
at line 865
bool
isSelfOrAncestorOf(HasNode $other)
Get whether the node is itself or an ancestor of other node, including immediate parent.
at line 873
bool
hasMoved()
Get whether the node has moved since last save.
at line 878
protected array
getArrayableRelations()
No description
at line 890
protected bool
hasForceDeleting()
Get whether user is intended to delete the model from database entirely.
at line 898
array
getBounds()
No description
at line 903
HasNode
setLft(mixed $value)
No description
at line 910
HasNode
setRgt(mixed $value)
No description
at line 917
HasNode
setParentId(mixed $value)
No description
at line 924
protected HasNode
dirtyBounds()
No description
at line 950
protected void
assertSameScope(HasNode $node)
No description
at line 963
protected bool
isSameScope(HasNode $node)
No description
at line 978
HasNode
replicate(array|null $except = null)
No description