October\Rain\Database\TreeCollection

Overview

TreeCollection is a custom collection used by NestedTree trait.

General access methods:

$collection->toNested(); // Converts collection to an eager loaded one.

Extends
Implements
  • ArrayAccess
  • Illuminate\Contracts\Support\CanBeEscapedWhenCastToString
  • Illuminate\Support\Enumerable
  • Traversable
  • Stringable
  • JsonSerializable
  • Illuminate\Contracts\Support\Jsonable
  • IteratorAggregate
  • Countable
  • Illuminate\Contracts\Support\Arrayable
  • Illuminate\Contracts\Queue\QueueableCollection

Protected Properties

There are no protected properties in the class.

Show inherited protected properties

Inherited Protected Properties

  • $items - The items contained in the collection. (defined in Illuminate\Support\Collection)
  • $escapeWhenCastingToString - Indicates that the object's string representation should be escaped when __toString is invoked. (defined in Illuminate\Support\Collection)
  • $proxies - The methods that can be proxied. (defined in Illuminate\Support\Collection)
  • $macros - The registered string macros. (defined in Illuminate\Support\Collection)

Public Methods

public listsNested()

public listsNested(
    string $value,
    string $key = null,
    string $indent = '   '
): array 

listsNested gets an array with values of a given column. Values are indented according to their depth.

public toNested()

public toNested(
    bool $removeOrphans = true
): October\Rain\Database\Collection 

toNested converts a flat collection of nested set models to an set where children is eager loaded. removeOrphans removes nodes that exist without their parents.

Show inherited public methods

Inherited Public Methods

  • __call() - Dynamically handle calls to the class. (defined in Illuminate\Support\Collection)
  • __callStatic() - Dynamically handle calls to the class. (defined in Illuminate\Support\Collection)
  • __construct() - Create a new collection. (defined in Illuminate\Support\Collection)
  • __get() - Dynamically access collection proxies. (defined in Illuminate\Support\Collection)
  • __toString() - Convert the collection to its string representation. (defined in Illuminate\Support\Collection)
  • add() - Add an item to the collection. (defined in Illuminate\Support\Collection)
  • all() - Get all of the items in the collection. (defined in Illuminate\Support\Collection)
  • append() - Append an attribute across the entire collection. (defined in Illuminate\Database\Eloquent\Collection)
  • average() - Alias for the "avg" method. (defined in Illuminate\Support\Collection)
  • avg() - Get the average value of a given key. (defined in Illuminate\Support\Collection)
  • chunk() - Chunk the collection into chunks of the given size. (defined in Illuminate\Support\Collection)
  • chunkWhile() - Chunk the collection into chunks with a callback. (defined in Illuminate\Support\Collection)
  • collapse() - Collapse the collection of items into a single array. (defined in Illuminate\Database\Eloquent\Collection)
  • collect() - Collect the values into a collection. (defined in Illuminate\Support\Collection)
  • combine() - Create a collection by using this collection for keys and another for its values. (defined in Illuminate\Support\Collection)
  • concat() - Push all of the given items onto the collection. (defined in Illuminate\Support\Collection)
  • contains() - Determine if a key exists in the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • containsOneItem() - Determine if the collection contains a single item. (defined in Illuminate\Support\Collection)
  • containsStrict() - Determine if an item exists, using strict comparison. (defined in Illuminate\Support\Collection)
  • count() - Count the number of items in the collection. (defined in Illuminate\Support\Collection)
  • countBy() - Count the number of items in the collection by a field or using a callback. (defined in Illuminate\Database\Eloquent\Collection)
  • crossJoin() - Cross join with the given lists, returning all possible permutations. (defined in Illuminate\Support\Collection)
  • dd() - Dump the items and end the script. (defined in Illuminate\Support\Collection)
  • diff() - Diff the collection with the given items. (defined in Illuminate\Database\Eloquent\Collection)
  • diffAssoc() - Get the items in the collection whose keys and values are not present in the given items. (defined in Illuminate\Support\Collection)
  • diffAssocUsing() - Get the items in the collection whose keys and values are not present in the given items, using the callback. (defined in Illuminate\Support\Collection)
  • diffKeys() - Get the items in the collection whose keys are not present in the given items. (defined in Illuminate\Support\Collection)
  • diffKeysUsing() - Get the items in the collection whose keys are not present in the given items, using the callback. (defined in Illuminate\Support\Collection)
  • diffUsing() - Get the items in the collection that are not present in the given items, using the callback. (defined in Illuminate\Support\Collection)
  • doesntContain() - Determine if an item is not contained in the collection. (defined in Illuminate\Support\Collection)
  • dump() - Dump the items. (defined in Illuminate\Support\Collection)
  • duplicates() - Retrieve duplicate items from the collection. (defined in Illuminate\Support\Collection)
  • duplicatesStrict() - Retrieve duplicate items from the collection using strict comparison. (defined in Illuminate\Support\Collection)
  • each() - Execute a callback over each item. (defined in Illuminate\Support\Collection)
  • eachSpread() - Execute a callback over each nested chunk of items. (defined in Illuminate\Support\Collection)
  • empty() - Create a new instance with no items. (defined in Illuminate\Support\Collection)
  • escapeWhenCastingToString() - Indicate that the model's string representation should be escaped when __toString is invoked. (defined in Illuminate\Support\Collection)
  • every() - Determine if all items pass the given truth test. (defined in Illuminate\Support\Collection)
  • except() - Returns all models in the collection except the models with specified keys. (defined in Illuminate\Database\Eloquent\Collection)
  • filter() - Run a filter over each of the items. (defined in Illuminate\Support\Collection)
  • find() - Find a model in the collection by key. (defined in Illuminate\Database\Eloquent\Collection)
  • first() - Get the first item from the collection passing the given truth test. (defined in Illuminate\Support\Collection)
  • firstOrFail() - Get the first item in the collection but throw an exception if no matching items exist. (defined in Illuminate\Support\Collection)
  • firstWhere() - Get the first item by the given key value pair. (defined in Illuminate\Support\Collection)
  • flatMap() - Map a collection and flatten the result by a single level. (defined in Illuminate\Support\Collection)
  • flatten() - Get a flattened array of the items in the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • flip() - Flip the items in the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • flushMacros() - Flush the existing macros. (defined in Illuminate\Support\Collection)
  • forPage() - "Paginate" the collection by slicing it into a smaller collection. (defined in Illuminate\Support\Collection)
  • forget() - Remove an item from the collection by key. (defined in Illuminate\Support\Collection)
  • fresh() - Reload a fresh model instance from the database for all the entities. (defined in Illuminate\Database\Eloquent\Collection)
  • get() - Get an item from the collection by key. (defined in Illuminate\Support\Collection)
  • getCachingIterator() - Get a CachingIterator instance. (defined in Illuminate\Support\Collection)
  • getDictionary() - Get a dictionary keyed by primary keys. (defined in Illuminate\Database\Eloquent\Collection)
  • getIterator() - Get an iterator for the items. (defined in Illuminate\Support\Collection)
  • getOrPut() - Get an item from the collection by key or add it to collection if it does not exist. (defined in Illuminate\Support\Collection)
  • getQueueableClass() - Get the type of the entities being queued. (defined in Illuminate\Database\Eloquent\Collection)
  • getQueueableConnection() - Get the connection of the entities being queued. (defined in Illuminate\Database\Eloquent\Collection)
  • getQueueableIds() - Get the identifiers for all of the entities. (defined in Illuminate\Database\Eloquent\Collection)
  • getQueueableRelations() - Get the relationships of the entities being queued. (defined in Illuminate\Database\Eloquent\Collection)
  • groupBy() - Group an associative array by a field or using a callback. (defined in Illuminate\Support\Collection)
  • has() - Determine if an item exists in the collection by key. (defined in Illuminate\Support\Collection)
  • hasAny() - Determine if any of the keys exist in the collection. (defined in Illuminate\Support\Collection)
  • hasMacro() - Checks if macro is registered. (defined in Illuminate\Support\Collection)
  • implode() - Concatenate values of a given key as a string. (defined in Illuminate\Support\Collection)
  • intersect() - Intersect the collection with the given items. (defined in Illuminate\Database\Eloquent\Collection)
  • intersectAssoc() - Intersect the collection with the given items with additional index check. (defined in Illuminate\Support\Collection)
  • intersectAssocUsing() - Intersect the collection with the given items with additional index check, using the callback. (defined in Illuminate\Support\Collection)
  • intersectByKeys() - Intersect the collection with the given items by key. (defined in Illuminate\Support\Collection)
  • intersectUsing() - Intersect the collection with the given items, using the callback. (defined in Illuminate\Support\Collection)
  • isEmpty() - Determine if the collection is empty or not. (defined in Illuminate\Support\Collection)
  • isNotEmpty() - Determine if the collection is not empty. (defined in Illuminate\Support\Collection)
  • join() - Join all items from the collection using a string. The final items can use a separate glue string. (defined in Illuminate\Support\Collection)
  • jsonSerialize() - Convert the object into something JSON serializable. (defined in Illuminate\Support\Collection)
  • keyBy() - Key an associative array by a field or using a callback. (defined in Illuminate\Support\Collection)
  • keys() - Get the keys of the collection items. (defined in Illuminate\Database\Eloquent\Collection)
  • last() - Get the last item from the collection. (defined in Illuminate\Support\Collection)
  • lazy() - Get a lazy collection for the items in this collection. (defined in Illuminate\Support\Collection)
  • lists() - Get an array with the values of a given key. (defined in October\Rain\Database\Collection)
  • load() - Load a set of relationships onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadAggregate() - Load a set of aggregations over relationship's column onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadAvg() - Load a set of relationship's average column values onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadCount() - Load a set of relationship counts onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadExists() - Load a set of related existences onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadMax() - Load a set of relationship's max column values onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadMin() - Load a set of relationship's min column values onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadMissing() - Load a set of relationships onto the collection if they are not already eager loaded. (defined in Illuminate\Database\Eloquent\Collection)
  • loadMorph() - Load a set of relationships onto the mixed relationship collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadMorphCount() - Load a set of relationship counts onto the mixed relationship collection. (defined in Illuminate\Database\Eloquent\Collection)
  • loadSum() - Load a set of relationship's column summations onto the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • macro() - Register a custom macro. (defined in Illuminate\Support\Collection)
  • make() - Create a new collection instance if the value isn't one already. (defined in Illuminate\Support\Collection)
  • makeHidden() - Make the given, typically visible, attributes hidden across the entire collection. (defined in Illuminate\Database\Eloquent\Collection)
  • makeVisible() - Make the given, typically hidden, attributes visible across the entire collection. (defined in Illuminate\Database\Eloquent\Collection)
  • map() - Run a map over each of the items. (defined in Illuminate\Database\Eloquent\Collection)
  • mapInto() - Map the values into a new class. (defined in Illuminate\Support\Collection)
  • mapSpread() - Run a map over each nested chunk of items. (defined in Illuminate\Support\Collection)
  • mapToDictionary() - Run a dictionary map over the items. (defined in Illuminate\Support\Collection)
  • mapToGroups() - Run a grouping map over the items. (defined in Illuminate\Support\Collection)
  • mapWithKeys() - Run an associative map over each of the items. (defined in Illuminate\Database\Eloquent\Collection)
  • max() - Get the max value of a given key. (defined in Illuminate\Support\Collection)
  • median() - Get the median of a given key. (defined in Illuminate\Support\Collection)
  • merge() - Merge the collection with the given items. (defined in Illuminate\Database\Eloquent\Collection)
  • mergeRecursive() - Recursively merge the collection with the given items. (defined in Illuminate\Support\Collection)
  • min() - Get the min value of a given key. (defined in Illuminate\Support\Collection)
  • mixin() - Mix another object into the class. (defined in Illuminate\Support\Collection)
  • mode() - Get the mode of a given key. (defined in Illuminate\Support\Collection)
  • modelKeys() - Get the array of primary keys. (defined in Illuminate\Database\Eloquent\Collection)
  • nth() - Create a new collection consisting of every n-th element. (defined in Illuminate\Support\Collection)
  • offsetExists() - Determine if an item exists at an offset. (defined in Illuminate\Support\Collection)
  • offsetGet() - Get an item at a given offset. (defined in Illuminate\Support\Collection)
  • offsetSet() - Set the item at a given offset. (defined in Illuminate\Support\Collection)
  • offsetUnset() - Unset the item at a given offset. (defined in Illuminate\Support\Collection)
  • only() - Returns only the models from the collection with the specified keys. (defined in Illuminate\Database\Eloquent\Collection)
  • pad() - Pad collection to the specified length with a value. (defined in Illuminate\Database\Eloquent\Collection)
  • partition() - Partition the collection into two arrays using the given callback or key. (defined in Illuminate\Support\Collection)
  • pipe() - Pass the collection to the given callback and return the result. (defined in Illuminate\Support\Collection)
  • pipeInto() - Pass the collection into a new class. (defined in Illuminate\Support\Collection)
  • pipeThrough() - Pass the collection through a series of callable pipes and return the result. (defined in Illuminate\Support\Collection)
  • pluck() - Get an array with the values of a given key. (defined in Illuminate\Database\Eloquent\Collection)
  • pop() - Get and remove the last N items from the collection. (defined in Illuminate\Support\Collection)
  • prepend() - Push an item onto the beginning of the collection. (defined in Illuminate\Support\Collection)
  • proxy() - Add a method to the list of proxied methods. (defined in Illuminate\Support\Collection)
  • pull() - Get and remove an item from the collection. (defined in Illuminate\Support\Collection)
  • push() - Push one or more items onto the end of the collection. (defined in Illuminate\Support\Collection)
  • put() - Put an item in the collection by key. (defined in Illuminate\Support\Collection)
  • random() - Get one or a specified number of items randomly from the collection. (defined in Illuminate\Support\Collection)
  • range() - Create a collection with the given range. (defined in Illuminate\Support\Collection)
  • reduce() - Reduce the collection to a single value. (defined in Illuminate\Support\Collection)
  • reduceSpread() - Reduce the collection to multiple aggregate values. (defined in Illuminate\Support\Collection)
  • reject() - Create a collection of all elements that do not pass a given truth test. (defined in Illuminate\Support\Collection)
  • replace() - Replace the collection items with the given items. (defined in Illuminate\Support\Collection)
  • replaceRecursive() - Recursively replace the collection items with the given items. (defined in Illuminate\Support\Collection)
  • reverse() - Reverse items order. (defined in Illuminate\Support\Collection)
  • search() - Search the collection for a given value and return the corresponding key if successful. (defined in Illuminate\Support\Collection)
  • setHidden() - Set the hidden attributes across the entire collection. (defined in Illuminate\Database\Eloquent\Collection)
  • setVisible() - Set the visible attributes across the entire collection. (defined in Illuminate\Database\Eloquent\Collection)
  • shift() - Get and remove the first N items from the collection. (defined in Illuminate\Support\Collection)
  • shuffle() - Shuffle the items in the collection. (defined in Illuminate\Support\Collection)
  • skip() - Skip the first {$count} items. (defined in Illuminate\Support\Collection)
  • skipUntil() - Skip items in the collection until the given condition is met. (defined in Illuminate\Support\Collection)
  • skipWhile() - Skip items in the collection while the given condition is met. (defined in Illuminate\Support\Collection)
  • slice() - Slice the underlying collection array. (defined in Illuminate\Support\Collection)
  • sliding() - Create chunks representing a "sliding window" view of the items in the collection. (defined in Illuminate\Support\Collection)
  • sole() - Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. (defined in Illuminate\Support\Collection)
  • some() - Alias for the "contains" method. (defined in Illuminate\Support\Collection)
  • sort() - Sort through each item with a callback. (defined in Illuminate\Support\Collection)
  • sortBy() - Sort the collection using the given callback. (defined in Illuminate\Support\Collection)
  • sortByDesc() - Sort the collection in descending order using the given callback. (defined in Illuminate\Support\Collection)
  • sortDesc() - Sort items in descending order. (defined in Illuminate\Support\Collection)
  • sortKeys() - Sort the collection keys. (defined in Illuminate\Support\Collection)
  • sortKeysDesc() - Sort the collection keys in descending order. (defined in Illuminate\Support\Collection)
  • sortKeysUsing() - Sort the collection keys using a callback. (defined in Illuminate\Support\Collection)
  • splice() - Splice a portion of the underlying collection array. (defined in Illuminate\Support\Collection)
  • split() - Split a collection into a certain number of groups. (defined in Illuminate\Support\Collection)
  • splitIn() - Split a collection into a certain number of groups, and fill the first groups completely. (defined in Illuminate\Support\Collection)
  • sum() - Get the sum of the given values. (defined in Illuminate\Support\Collection)
  • take() - Take the first or last {$limit} items. (defined in Illuminate\Support\Collection)
  • takeUntil() - Take items in the collection until the given condition is met. (defined in Illuminate\Support\Collection)
  • takeWhile() - Take items in the collection while the given condition is met. (defined in Illuminate\Support\Collection)
  • tap() - Pass the collection to the given callback and then return it. (defined in Illuminate\Support\Collection)
  • times() - Create a new collection by invoking the callback a given amount of times. (defined in Illuminate\Support\Collection)
  • toArray() - Get the collection of items as a plain array. (defined in Illuminate\Support\Collection)
  • toBase() - Get a base Support collection instance from this collection. (defined in Illuminate\Support\Collection)
  • toJson() - Get the collection of items as JSON. (defined in Illuminate\Support\Collection)
  • toQuery() - Get the Eloquent query builder from the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • transform() - Transform each item in the collection using a callback. (defined in Illuminate\Support\Collection)
  • undot() - Convert a flatten "dot" notation array into an expanded array. (defined in Illuminate\Support\Collection)
  • union() - Union the collection with the given items. (defined in Illuminate\Support\Collection)
  • unique() - Return only unique items from the collection. (defined in Illuminate\Database\Eloquent\Collection)
  • uniqueStrict() - Return only unique items from the collection array using strict comparison. (defined in Illuminate\Support\Collection)
  • unless() - Apply the callback if the given "value" is (or resolves to) falsy. (defined in Illuminate\Support\Collection)
  • unlessEmpty() - Apply the callback unless the collection is empty. (defined in Illuminate\Support\Collection)
  • unlessNotEmpty() - Apply the callback unless the collection is not empty. (defined in Illuminate\Support\Collection)
  • unwrap() - Get the underlying items from the given collection if applicable. (defined in Illuminate\Support\Collection)
  • value() - Get a single key's value from the first matching item in the collection. (defined in Illuminate\Support\Collection)
  • values() - Reset the keys on the underlying array. (defined in Illuminate\Support\Collection)
  • when() - Apply the callback if the given "value" is (or resolves to) truthy. (defined in Illuminate\Support\Collection)
  • whenEmpty() - Apply the callback if the collection is empty. (defined in Illuminate\Support\Collection)
  • whenNotEmpty() - Apply the callback if the collection is not empty. (defined in Illuminate\Support\Collection)
  • where() - Filter items by the given key value pair. (defined in Illuminate\Support\Collection)
  • whereBetween() - Filter items such that the value of the given key is between the given values. (defined in Illuminate\Support\Collection)
  • whereIn() - Filter items by the given key value pair. (defined in Illuminate\Support\Collection)
  • whereInStrict() - Filter items by the given key value pair using strict comparison. (defined in Illuminate\Support\Collection)
  • whereInstanceOf() - Filter the items, removing any items that don't match the given type(s). (defined in Illuminate\Support\Collection)
  • whereNotBetween() - Filter items such that the value of the given key is not between the given values. (defined in Illuminate\Support\Collection)
  • whereNotIn() - Filter items by the given key value pair. (defined in Illuminate\Support\Collection)
  • whereNotInStrict() - Filter items by the given key value pair using strict comparison. (defined in Illuminate\Support\Collection)
  • whereNotNull() - Filter items where the value for the given key is not null. (defined in Illuminate\Support\Collection)
  • whereNull() - Filter items where the value for the given key is null. (defined in Illuminate\Support\Collection)
  • whereStrict() - Filter items by the given key value pair using strict comparison. (defined in Illuminate\Support\Collection)
  • wrap() - Wrap the given value in a collection if applicable. (defined in Illuminate\Support\Collection)
  • zip() - Zip the collection together with one or more arrays. (defined in Illuminate\Database\Eloquent\Collection)

Protected Methods

Show inherited protected methods

Inherited Protected Methods

  • duplicateComparator() - Get the comparison function to detect duplicates. (defined in Illuminate\Database\Eloquent\Collection)
  • equality() - Make a function to check an item's equality. (defined in Illuminate\Support\Collection)
  • getArrayableItems() - Results array of items from Collection or Arrayable. (defined in Illuminate\Support\Collection)
  • getQueueableModelClass() - Get the queueable class name for the given model. (defined in Illuminate\Database\Eloquent\Collection)
  • identity() - Make a function that returns what's passed to it. (defined in Illuminate\Support\Collection)
  • loadMissingRelation() - Load a relationship path if it is not already eager loaded. (defined in Illuminate\Database\Eloquent\Collection)
  • negate() - Make a function using another function, by negating its result. (defined in Illuminate\Support\Collection)
  • operatorForWhere() - Get an operator checker callback. (defined in Illuminate\Support\Collection)
  • sortByMany() - Sort the collection using multiple comparisons. (defined in Illuminate\Support\Collection)
  • useAsCallable() - Determine if the given value is callable, but not a string. (defined in Illuminate\Support\Collection)
  • valueRetriever() - Get a value retrieving callback. (defined in Illuminate\Support\Collection)