DataFilter API
Complete API reference for DataFilter.
Static Methods
Section titled “Static Methods”make(array $data): self
Section titled “make(array $data): self”Create a new instance.
$filter = DataFilter::make($data);Filter Methods
Section titled “Filter Methods”only(array $keys): self
Section titled “only(array $keys): self”Keep only specified keys.
$filter->only(['name', 'email']);except(array $keys): self
Section titled “except(array $keys): self”Remove specified keys.
$filter->except(['password', 'token']);where(string $key, mixed $value): self
Section titled “where(string $key, mixed $value): self”Filter by key-value.
$filter->where('status', 'active');whereIn(string $key, array $values): self
Section titled “whereIn(string $key, array $values): self”Filter by key in values.
$filter->whereIn('role', ['admin', 'moderator']);whereNotNull(string $key): self
Section titled “whereNotNull(string $key): self”Filter where key is not null.
$filter->whereNotNull('email');Transform Methods
Section titled “Transform Methods”map(callable $callback): self
Section titled “map(callable $callback): self”Transform each item.
$filter->map(fn($item) => strtoupper($item));filter(callable $callback): self
Section titled “filter(callable $callback): self”Filter items by callback.
$filter->filter(fn($item) => $item['active']);Result Methods
Section titled “Result Methods”toArray(): array
Section titled “toArray(): array”Get filtered array.
$result = $filter->toArray();first(): mixed
Section titled “first(): mixed”Get first item.
$first = $filter->first();count(): int
Section titled “count(): int”Count items.
$count = $filter->count();See Also
Section titled “See Also”- DataFilter Guide - Complete guide