add
Add an object
Returns:
C<Collection> of C<Model> objects
as
Set model for collection
asOptions
Return an array ref containing [{ value => $value, label => $label }, ...]
avg
Return the average value for given $field
collect
Instantiate a new collection
count
Return the size of objects
each
Map through each object and call the callback
exclude
Exclude objects that doesn't match criteria
Returns:
C<Collection> of C<Model> objects
filter
Filter objects by callback
Returns:
C<Collection> of C<Model> objects
find
Find object by primary key, of if args is a hash ref then find first object matching given args
Returns:
C<Model> object
findOrNew
Find object or create a new instance
Returns:
C<Model> object
first
Get first object
Returns:
C<Model> object
firstOrNew
Get first object if exists, otherwise create one
Returns:
C<Model> object
get
Get object by index
Returns:
C<Collection> of C<Model> objects
indexOf
Get the index of an object
Returns:
Integer index
intersect
Return a new collection containing only items that exist in both collections.
Uses $key to compare objects (defaults to primary_key).
Returns:
C<Collection> of C<Model> objects
last
Get last object
Returns:
C<Model> object
lists
Return an array ref containing all the fields from all objects for the given $field.
Return a hash ref containing $key_field => $value_field if both are given.
max
Return the maximum value for given $field
min
Return the minimum value for given $field
missing
Return a new collection containing only items that exist in this collection
but not in the other collection.
Uses $key to compare objects (defaults to primary_key).
Returns:
C<Collection> of C<Model> objects
newObject
Instantiate new object
Returns:
C<Model> object
next
Get next object
Returns:
C<Model> object
only
Return an array ref containing only given @keys
orderBy
Order collection
page
Take a collection containing only the results from a given page
Returns:
C<Collection> of C<Model> objects
remove
Remove an object
reset
Reset index
search
Search objects by given args
Returns:
C<Collection> of C<Model> objects
slice
Take a slice from the collection
Returns:
C<Collection> of C<Model> objects
splice
Splice objects
sum
Sum by $field
toArray
Convert collection to array ref
toCsv
Convert collection to CSV string
toJson
Convert collection to JSON string
touch
Touch collections model
unique
Return an array ref containing only unique values for given $field
where
Search objects where field is equal to value
Returns:
C<Collection> of C<Model> objects
whereIn
Search objects where field is in $array
Returns:
C<Collection> of C<Model> objects
whereNotIn
Search objects where field is not in $array
Returns:
C<Collection> of C<Model> objects
__first
Find first object that match $callback
Returns:
C<Model> object
__list
Return a scalar, or an array if the value is a collection