fields()) ->filter(fn (Field $field): bool => $field instanceof FilterableField) ->map(fn (FilterableField $field): Filter => $field->getFilter()) ->push(new TrashedFilter()) ->all(); } /** * @return Sort[] */ public function sorts(): array { return collect($this->fields()) ->filter(fn (Field $field): bool => $field instanceof SortableField) ->map(fn (SortableField $field): Sort => $field->getSort()) ->push(new RandomSort()) ->all(); } /** * Get the schema of the relation by path. */ public function relation(string $path): ?Schema { $relationInclude = Arr::first($this->allowedIncludes(), fn (AllowedInclude $include): bool => $include->path() === $path); /** @phpstan-ignore-next-line */ return $relationInclude?->schema(); } /** * @return AllowedInclude[] */ abstract public function allowedIncludes(): array; }