Documentation

Chainer
in package

Table of Contents

add()  : mixed
Magic method to add an element to the collection
addRelation()  : mixed
Adds a relation to the chain, this is triggered when a model's relation magic method is called.
clear()  : mixed
Magic method to clear a collection
exists()  : bool
Magic method to check if a condition exists in the collection
fetch()  : array<string|int, mixed>
Magic method to fetch a filtered collection (or all of it)
filterCollection()  : mixed
Filter a collection based on the conditions previously set via 'with' The condition can be: 1) array: all the attributes will be compared against each collection element.
getResult()  : array<string|int, mixed>
Internal method to make it easier to get results
handleArray()  : array<string|int, mixed>
Handle conditions in array format.
handleCallable()  : array<string|int, mixed>
Handle conditions in Callable format This method requires a function that returns a boolean.
handleConditions()  : mixed
Magic method to handle operations that don't interact directly with the collection, they just store information in the chain for later filtering or manipulation.
handleFlex()  : array<string|int, mixed>
Handles conditions in the Flex Model format This method compares model ids only.
handleMethods()  : mixed
Handle all the available chained methods.
remove()  : mixed
Magic method to remove elements from the collection.

Methods

add()

Magic method to add an element to the collection

public add(mixed $model, mixed $arguments) : mixed
Parameters
$model : mixed
$arguments : mixed
Return values
mixed

addRelation()

Adds a relation to the chain, this is triggered when a model's relation magic method is called.

public addRelation(Flex $model, mixed $name, mixed $arguments) : mixed

Example: $company->users() 'users' is the magic method, which is just the relation name with the first letter with low case.

Parameters
$model : Flex
$name : mixed
$arguments : mixed
Return values
mixed

clear()

Magic method to clear a collection

public clear(mixed $model, mixed $arguments) : mixed
Parameters
$model : mixed
$arguments : mixed
Return values
mixed

exists()

Magic method to check if a condition exists in the collection

public exists(mixed $model, mixed $arguments) : bool
Parameters
$model : mixed
$arguments : mixed
Return values
bool

fetch()

Magic method to fetch a filtered collection (or all of it)

public fetch(mixed $model, mixed $arguments) : array<string|int, mixed>
Parameters
$model : mixed
$arguments : mixed
Return values
array<string|int, mixed>

filterCollection()

Filter a collection based on the conditions previously set via 'with' The condition can be: 1) array: all the attributes will be compared against each collection element.

public filterCollection(Flex $parent) : mixed
  1. callable: if the callable returns true, then it qualifies.
  2. Flex model: In this case, only ids are compared.
Parameters
$parent : Flex
Return values
mixed

getResult()

Internal method to make it easier to get results

public getResult(mixed $not, mixed $collection) : array<string|int, mixed>
Parameters
$not : mixed
$collection : mixed
Return values
array<string|int, mixed>

handleArray()

Handle conditions in array format.

public handleArray(mixed $model, mixed $relation, mixed $condition, mixed $collection) : array<string|int, mixed>

This method checks every property set in the array against each of the collection's models.

Parameters
$model : mixed
$relation : mixed
$condition : mixed
$collection : mixed
Return values
array<string|int, mixed>

handleCallable()

Handle conditions in Callable format This method requires a function that returns a boolean.

public handleCallable(mixed $model, mixed $condition, mixed $collection) : array<string|int, mixed>

If it returns true, then it's considered as a match.

Parameters
$model : mixed
$condition : mixed
$collection : mixed
Return values
array<string|int, mixed>

handleConditions()

Magic method to handle operations that don't interact directly with the collection, they just store information in the chain for later filtering or manipulation.

public handleConditions(mixed $name, mixed $model, mixed $arguments) : mixed
Parameters
$name : mixed
$model : mixed
$arguments : mixed
Return values
mixed

handleFlex()

Handles conditions in the Flex Model format This method compares model ids only.

public handleFlex(mixed $model, mixed $relation, mixed $condition, mixed $collection) : array<string|int, mixed>
Parameters
$model : mixed
$relation : mixed
$condition : mixed
$collection : mixed
Return values
array<string|int, mixed>

handleMethods()

Handle all the available chained methods.

public handleMethods(Flex $model, mixed $name, mixed $arguments) : mixed
Parameters
$model : Flex
$name : mixed
$arguments : mixed
Return values
mixed

remove()

Magic method to remove elements from the collection.

public remove(mixed $model, mixed $arguments) : mixed
Parameters
$model : mixed
$arguments : mixed
Return values
mixed

Search results