GetByTrait
Find entities by filters.
Caching lives at the Api presenter boundary (wire-payload query cache), not here. The
service always reads from the database; $useCache is kept only for backward compatible
signatures.
Tags
Table of Contents
Methods
- existsBy() : bool
- Check if entity exists by filters.
- findAllBy() : array<int, T>
- Find entities by filters.
- findBy() : T|null
- Find one entity by filters.
- findByOrFail() : T
- Find one entity by filters or throw exception.
- getEntityClass() : class-string
Methods
existsBy()
Check if entity exists by filters.
public
existsBy(array<string|int, mixed> $filters[, bool $useCache = true ]) : bool
Parameters
- $filters : array<string|int, mixed>
-
Filter conditions
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Return values
bool —True if entity exists
findAllBy()
Find entities by filters.
public
findAllBy(array<string|int, mixed> $filters[, array<string|int, mixed> $includes = [] ][, array<string|int, mixed>|null $order = null ][, int|null $offset = null ][, int|null $limit = null ][, bool $useCache = true ]) : array<int, T>
Parameters
- $filters : array<string|int, mixed>
-
Filter conditions (e.g., ['activated' => 1, 'userId' => 5])
- $includes : array<string|int, mixed> = []
-
Relations to load
- $order : array<string|int, mixed>|null = null
-
Sorting
- $offset : int|null = null
-
Offset
- $limit : int|null = null
-
Limit
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Return values
array<int, T> —Array of entities
findBy()
Find one entity by filters.
public
findBy(array<string|int, mixed> $filters[, array<string|int, mixed> $includes = [] ][, bool $useCache = true ]) : T|null
Parameters
- $filters : array<string|int, mixed>
-
Filter conditions
- $includes : array<string|int, mixed> = []
-
Relations to load
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Return values
T|null —Entity or null if not found
findByOrFail()
Find one entity by filters or throw exception.
public
findByOrFail(array<string|int, mixed> $filters[, array<string|int, mixed> $includes = [] ][, bool $useCache = true ]) : T
Parameters
- $filters : array<string|int, mixed>
-
Filter conditions
- $includes : array<string|int, mixed> = []
-
Relations to load
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Tags
Return values
T —Entity instance
getEntityClass()
protected
abstract getEntityClass() : class-string