$files->filterBy()

Filters the collection by a key and value.

Example

// filter by extension
$images = $page->images()->filterBy('extension', 'jpg');

// filter by custom field value
$images = $page->images()->filterBy('gallery', 'gallery-2');

// filter by filenames containing a string
$files = $page->files()->filterBy('filename', '*=', '-document');

// filter all types except documents
$files = $page->files()->filterBy('type', '!=', 'document');

Available filter methods

Method Function
== all values, which match exactly
!= all values, which don't match
*= all values, which contain the given string
> all values, which are greater than the given value
>= all values, which are greater or equal the given value
< all values, which are smaller than the given value
<= all values, which are smaller or equal the given value