Skip to content

Filtering and Ordering ​

Resources that support filters accept an associative array through the filters argument, forwarded as-is to the BioTime API as query parameters. Supported filter keys are resource-specific — the SDK doesn't validate them, it passes whatever you provide through to the device, so filters must be supported by the corresponding BioTime API endpoint.

Ordering ​

Every filterable resource supports an ordering key to control sort order.

Ascending — pass the column name directly:

php
$employees = $biotime->employees()->list(
    filters: ['ordering' => 'first_name'],
);

Descending — prefix the column name with -:

php
$employees = $biotime->employees()->list(
    filters: ['ordering' => '-first_name'],
);
ExampleMeaning
ordering => 'first_name'first_name ASC
ordering => '-first_name'first_name DESC
ordering => 'id'id ASC
ordering => '-id'id DESC

Documented filters by resource ​

These are the filter shapes documented in each resource class's PHPDoc (@param array{...} $filters):

ResourceFilters
Employeesemp_code, emp_code_icontains, first_name, first_name_icontains, last_name, last_name_icontains, department, areas, plus ordering
Attendancesemp_code, terminal_sn, terminal_alias, plus ordering and the startTime/endTime range parameters
Departmentsdept_code, dept_name, dept_code_icontains, dept_name_icontains, plus ordering
Positionsposition_code, position_name, position_code_icontains, position_name_icontains, plus ordering
Areasarea_code, area_name, area_code_icontains, area_name_icontains, plus ordering
DevicesNot typed in the SDK; any query parameter supported by /iclock/api/terminals/ (e.g. state, ordering) can be passed through filters
Resignationsemployee (also available via the dedicated findByEmployee() helper), plus any parameter supported by /personnel/api/resigns/

TIP

_icontains filters perform a case-insensitive "contains" match; the exact filter, e.g. first_name vs. first_name_icontains, and its behavior, are defined by the BioTime device API itself.

Combining filters ​

php
$employees = $biotime->employees()->list(
    page: 1,
    perPage: 50,
    filters: [
        'department' => 3,
        'areas'      => 1,
        'ordering'   => '-first_name',
    ],
);

Filters work identically with list() and all() — see Pagination for the difference between the two.

Distributed under the MIT License.