Using Constraints

Often, you will not want to fetch every single instance of an entity for a particular collection but will want to constrain your result to a certain query. This can be achieved using a constraint.

Column constraint

Constraints can be applied against any column supported by the endpoint. By default, they will use an equals operator but this can be configured (see reference below).

$profiles = $omneo->profiles()->browse(
    (new Omneo\Constraint)
        ->where('tier', 'gold')
        ->where('created_at', '>', '2018-01-01')
);

Search constraint

Some entities allow searching by arbitrary value. This will perform a like query across a number of columns dependant on the entity.

$profiles = $omneo->profiles()->browse(
    (new Omneo\Constraint)->search('Mickey Mouse')
);

Operator reference

When adding an operator to your constraint, you should utilise the PHP Operator. The client will perform the necessary transformation to the Omneo Operator.

PHP Operator

Omneo Operator

=

eq

>

gt

>=

gte

<

lt

<=

lte

in

in

Last updated