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