class Builder extends Builder

Properties

protected NestedTree|Model $model

Methods

Collection
lists(string $column, string|null $key = null)

Get an array with the values of a given column.

from  Builder
Collection
dropdown(string $column, string|null $key = null)

Get an array with the values of a given column.

from  Builder
search(string $term, array $columns = [], string $mode = 'all')

Perform a search on this query for term found in columns.

from  Builder
orSearch(string $term, array $columns = [], string $mode = 'all')

Add an "or search where" clause to the query.

from  Builder
like(string $column, $value, string $side = 'both', string $boolean = 'and')

Convenient method for where like clause

from  Builder
orLike(string $column, $value, string $side = 'both')

Convenient method for or where like clause

from  Builder
$this
searchInternal($term, array $columns, $mode, $boolean)

Internal method to apply a search constraint to the query.

from  Builder
likeInternal($column, $value, $side = null, $boolean = 'and')

No description

from  Builder
array
pluckDates(string $column, string $keyFormat = 'Y-m', string $valueFormat = 'F Y')

Get an array with the values of dates.

from  Builder
LengthAwarePaginator
paginate(int $perPage = null, int|null $page = null, array $columns = ['*'], string $pageName = 'page')

Paginate the given query.

from  Builder
Paginator
simplePaginate(int $perPage = null, int|null $page = null, array $columns = ['*'], string $pageName = 'page')

Paginate the given query into a simple paginator.

from  Builder
Model
findOrNew(mixed $id, array $columns = ['*'])

Find a model by its primary key or return fresh model instance with filled attributes to use with forms.

from  Builder
array
getNodeData(mixed $id, bool $required = false)

Get node's lft and rgt values.

array
getPlainNodeData(mixed $id, bool $required = false)

Get plain node data.

$this
whereIsRoot()

Scope limits query to select just root node.

$this
whereAncestorOf(mixed $id, bool $andSelf = false, string $boolean = 'and')

Limit results to ancestors of specified node.

$this
orWhereAncestorOf($id, bool $andSelf = false)

No description

whereAncestorOrSelf($id)

No description

Collection
ancestorsOf(mixed $id, array $columns = ['*'])

Get ancestors of specified node.

Collection
ancestorsAndSelf($id, array $columns = ['*'])

No description

$this
whereNodeBetween(array $values, string $boolean = 'and', bool $not = false)

Add node selection statement between specified range.

$this
orWhereNodeBetween(array $values)

Add node selection statement between specified range joined with or operator.

$this
whereDescendantOf(mixed $id, string $boolean = 'and', bool $not = false, bool $andSelf = false)

Add constraint statement to descendants of specified node.

whereNotDescendantOf(mixed $id)

No description

orWhereDescendantOf(mixed $id)

No description

orWhereNotDescendantOf(mixed $id)

No description

$this
whereDescendantOrSelf($id, string $boolean = 'and', bool $not = false)

No description

Collection
descendantsOf(mixed $id, array $columns = ['*'], bool $andSelf = false)

Get descendants of specified node.

Collection
descendantsAndSelf($id, array $columns = ['*'])

No description

$this
whereIsBeforeOrAfter($id, $operator, $boolean)

No description

$this
whereIsAfter(mixed $id, string $boolean = 'and')

Constraint nodes to those that are after specified node.

$this
whereIsBefore(mixed $id, string $boolean = 'and')

Constraint nodes to those that are before specified node.

$this
whereIsLeaf()

No description

Builder[]|Collection
leaves(array $columns = ['*'])

No description

$this
withDepth(string $as = 'depth')

Include depth level into the result.

array
wrappedColumns()

Get wrapped lft and rgt column names.

string
wrappedTable()

Get a wrapped table name.

string
wrappedKey()

Wrap model's key name.

$this
withoutRoot()

Exclude root node from the result.

$this
hasParent() deprecated

Equivalent of withoutRoot.

$this
hasChildren() deprecated

Get only nodes that have children.

$this
defaultOrder(string $dir = 'asc')

Order by node position.

$this
reversed()

Order by reversed node position.

int
moveNode(mixed $key, int $position)

Move a node to the new position.

int
makeGap(int $cut, int $height)

Make or remove gap in the tree. Negative height will remove gap.

array
patch(array $params)

Get patch for columns.

string
columnPatch(string $col, array $params)

Get patch for single column.

array
countErrors()

Get statistics of errors of the tree.

Builder
getOdnessQuery()

No description

Builder
getDuplicatesQuery()

No description

Builder
getWrongParentQuery()

No description

$this
getMissingParentQuery()

No description

int
getTotalErrors()

Get the number of total errors of the tree.

bool
isBroken()

Get whether the tree is broken.

int
fixTree()

Fixes the tree based on parentage info.

static int
fixNodes(array $dictionary)

No description

static int
reorderNodes(array $dictionary, int $fixed, $parentId = null, int $cut = 1)

No description

int
rebuildTree(array $data, bool $delete = false)

Rebuild the tree based on raw data.

buildRebuildDictionary(array $dictionary, array $data, array $existing, mixed $parentId = null)

No description

$this
applyNestedSetScope(string|null $table = null)

No description

root(array $columns = ['*'])

Get the root node.

Details

in Builder at line 22
Collection lists(string $column, string|null $key = null)

Get an array with the values of a given column.

Parameters

string $column
string|null $key

Return Value

Collection

in Builder at line 35
Collection dropdown(string $column, string|null $key = null)

Get an array with the values of a given column.

Parameters

string $column
string|null $key

Return Value

Collection

Perform a search on this query for term found in columns.

Parameters

string $term

Search query

array $columns

Table columns to search

string $mode

Search mode: all, any, exact.

Return Value

Builder

in Builder at line 65
Builder orSearch(string $term, array $columns = [], string $mode = 'all')

Add an "or search where" clause to the query.

Parameters

string $term

Search query

array $columns

Table columns to search

string $mode

Search mode: all, any, exact.

Return Value

Builder

in Builder at line 80
Builder like(string $column, $value, string $side = 'both', string $boolean = 'and')

Convenient method for where like clause

Parameters

string $column
$value
string $side
string $boolean

Return Value

Builder

in Builder at line 94
Builder orLike(string $column, $value, string $side = 'both')

Convenient method for or where like clause

Parameters

string $column
$value
string $side

Return Value

Builder

in Builder at line 113
protected $this searchInternal($term, array $columns, $mode, $boolean)

Internal method to apply a search constraint to the query.

Mode can be any of these options:

  • all: result must contain all words
  • any: result can contain any word
  • exact: result must contain the exact phrase

Parameters

$term
array $columns
$mode
$boolean

Return Value

$this

in Builder at line 148
protected likeInternal($column, $value, $side = null, $boolean = 'and')

No description

Parameters

$column
$value
$side
$boolean

in Builder at line 178
array pluckDates(string $column, string $keyFormat = 'Y-m', string $valueFormat = 'F Y')

Get an array with the values of dates.

Parameters

string $column
string $keyFormat
string $valueFormat

Return Value

array

in Builder at line 211
LengthAwarePaginator paginate(int $perPage = null, int|null $page = null, array $columns = ['*'], string $pageName = 'page')

Paginate the given query.

Parameters

int $perPage
int|null $page
array $columns
string $pageName

Return Value

LengthAwarePaginator

Exceptions

InvalidArgumentException

in Builder at line 247
Paginator simplePaginate(int $perPage = null, int|null $page = null, array $columns = ['*'], string $pageName = 'page')

Paginate the given query into a simple paginator.

Parameters

int $perPage
int|null $page
array $columns
string $pageName

Return Value

Paginator

in Builder at line 282
Model findOrNew(mixed $id, array $columns = ['*'])

Find a model by its primary key or return fresh model instance with filled attributes to use with forms.

Parameters

mixed $id
array $columns

Return Value

Model

at line 33
array getNodeData(mixed $id, bool $required = false)

Since: 2.0

Get node's lft and rgt values.

Parameters

mixed $id
bool $required

Return Value

array

at line 59
array getPlainNodeData(mixed $id, bool $required = false)

Since: 2.0

Get plain node data.

Parameters

mixed $id
bool $required

Return Value

array

at line 69
$this whereIsRoot()

Scope limits query to select just root node.

Return Value

$this

at line 87
$this whereAncestorOf(mixed $id, bool $andSelf = false, string $boolean = 'and')

Since: 2.0

Limit results to ancestors of specified node.

Parameters

mixed $id
bool $andSelf
string $boolean

Return Value

$this

at line 131
$this orWhereAncestorOf($id, bool $andSelf = false)

No description

Parameters

$id
bool $andSelf

Return Value

$this

at line 141
Builder whereAncestorOrSelf($id)

No description

Parameters

$id

Return Value

Builder

at line 155
Collection ancestorsOf(mixed $id, array $columns = ['*'])

Since: 2.0

Get ancestors of specified node.

Parameters

mixed $id
array $columns

Return Value

Collection

at line 166
Collection ancestorsAndSelf($id, array $columns = ['*'])

No description

Parameters

$id
array $columns

Return Value

Collection

at line 181
$this whereNodeBetween(array $values, string $boolean = 'and', bool $not = false)

Since: 2.0

Add node selection statement between specified range.

Parameters

array $values
string $boolean
bool $not

Return Value

$this

at line 196
$this orWhereNodeBetween(array $values)

Since: 2.0

Add node selection statement between specified range joined with or operator.

Parameters

array $values

Return Value

$this

at line 212
$this whereDescendantOf(mixed $id, string $boolean = 'and', bool $not = false, bool $andSelf = false)

Since: 2.0

Add constraint statement to descendants of specified node.

Parameters

mixed $id
string $boolean
bool $not
bool $andSelf

Return Value

$this

at line 236
Builder whereNotDescendantOf(mixed $id)

No description

Parameters

mixed $id

Return Value

Builder

at line 246
Builder orWhereDescendantOf(mixed $id)

No description

Parameters

mixed $id

Return Value

Builder

at line 256
Builder orWhereNotDescendantOf(mixed $id)

No description

Parameters

mixed $id

Return Value

Builder

at line 268
$this whereDescendantOrSelf($id, string $boolean = 'and', bool $not = false)

No description

Parameters

$id
string $boolean
bool $not

Return Value

$this

at line 283
Collection descendantsOf(mixed $id, array $columns = ['*'], bool $andSelf = false)

Since: 2.0

Get descendants of specified node.

Parameters

mixed $id
array $columns
bool $andSelf

Return Value

Collection

at line 299
Collection descendantsAndSelf($id, array $columns = ['*'])

No description

Parameters

$id
array $columns

Return Value

Collection

at line 311
protected $this whereIsBeforeOrAfter($id, $operator, $boolean)

No description

Parameters

$id
$operator
$boolean

Return Value

$this

at line 347
$this whereIsAfter(mixed $id, string $boolean = 'and')

Since: 2.0

Constraint nodes to those that are after specified node.

Parameters

mixed $id
string $boolean

Return Value

$this

at line 361
$this whereIsBefore(mixed $id, string $boolean = 'and')

Since: 2.0

Constraint nodes to those that are before specified node.

Parameters

mixed $id
string $boolean

Return Value

$this

at line 369
$this whereIsLeaf()

No description

Return Value

$this

at line 381
Builder[]|Collection leaves(array $columns = ['*'])

No description

Parameters

array $columns

Return Value

Builder[]|Collection

at line 393
$this withDepth(string $as = 'depth')

Include depth level into the result.

Parameters

string $as

Return Value

$this

at line 422
protected array wrappedColumns()

Since: 2.0

Get wrapped lft and rgt column names.

Return Value

array

at line 438
protected string wrappedTable()

Since: 2.0

Get a wrapped table name.

Return Value

string

at line 449
protected string wrappedKey()

Since: 2.0

Wrap model's key name.

Return Value

string

at line 459
$this withoutRoot()

Exclude root node from the result.

Return Value

$this

at line 474
$this hasParent() deprecated

Since: 2.0

deprecated since v4.1

Equivalent of withoutRoot.

Return Value

$this

at line 489
$this hasChildren() deprecated

Since: 2.0

deprecated since v4.1

Get only nodes that have children.

Return Value

$this

at line 505
$this defaultOrder(string $dir = 'asc')

Order by node position.

Parameters

string $dir

Return Value

$this

at line 519
$this reversed()

Order by reversed node position.

Return Value

$this

at line 532
int moveNode(mixed $key, int $position)

Move a node to the new position.

Parameters

mixed $key
int $position

Return Value

int

at line 584
int makeGap(int $cut, int $height)

Since: 2.0

Make or remove gap in the tree. Negative height will remove gap.

Parameters

int $cut
int $height

Return Value

int

at line 604
protected array patch(array $params)

Since: 2.0

Get patch for columns.

Parameters

array $params

Return Value

array

at line 626
protected string columnPatch(string $col, array $params)

Since: 2.0

Get patch for single column.

Parameters

string $col
array $params

Return Value

string

at line 657
array countErrors()

Since: 2.0

Get statistics of errors of the tree.

Return Value

array

at line 687
protected Builder getOdnessQuery()

No description

Return Value

Builder

at line 703
protected Builder getDuplicatesQuery()

No description

Return Value

Builder

at line 733
protected Builder getWrongParentQuery()

No description

Return Value

Builder

at line 774
protected $this getMissingParentQuery()

No description

Return Value

$this

at line 809
int getTotalErrors()

Since: 2.0

Get the number of total errors of the tree.

Return Value

int

at line 820
bool isBroken()

Since: 2.0

Get whether the tree is broken.

Return Value

bool

at line 832
int fixTree()

Fixes the tree based on parentage info.

Nodes with invalid parent are saved as roots.

Return Value

int

The number of fixed nodes

at line 855
static protected int fixNodes(array $dictionary)

No description

Parameters

array $dictionary

Return Value

int

at line 881
static protected int reorderNodes(array $dictionary, int $fixed, $parentId = null, int $cut = 1)

No description

Parameters

array $dictionary
int $fixed
$parentId
int $cut

Return Value

int

at line 924
int rebuildTree(array $data, bool $delete = false)

Rebuild the tree based on raw data.

If item data does not contain primary key, new node will be created.

Parameters

array $data
bool $delete

Whether to delete nodes that exists but not in the data array

Return Value

int

at line 966
protected buildRebuildDictionary(array $dictionary, array $data, array $existing, mixed $parentId = null)

No description

Parameters

array $dictionary
array $data
array $existing
mixed $parentId

at line 1008
$this applyNestedSetScope(string|null $table = null)

No description

Parameters

string|null $table

Return Value

$this

at line 1020
Builder root(array $columns = ['*'])

Get the root node.

Parameters

array $columns

Return Value

Builder