CoolCMS API

GetByTrait

Provides `findBy()`.

Tags
template

Table of Contents

Methods

findBy()  : SingleQuery<string|int, T>
Finds one entity by filters and returns a `SingleQuery` object.

Methods

findBy()

Finds one entity by filters and returns a `SingleQuery` object.

public findBy([array<string|int, mixed> $filters = [] ][, string|array<string|int, mixed> $includes = [] ]) : SingleQuery<string|int, T>

Usage:

$query = $manager->findBy(['slug' => 'my-page'], ['translations']);
$entity = $query->include(['routes'])->execute(); // or ->get()
$title = $query->getTitle(); // magic call, forwarded to the entity
Parameters
$filters : array<string|int, mixed> = []

filters for the where conditions

$includes : string|array<string|int, mixed> = []

relations to load ['translations', 'routes'], or '*' for all

Return values
SingleQuery<string|int, T>
On this page

Search results