Skip to content

Commit

Permalink
Ensure appended attributes aren't returned in fields filter
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Aug 7, 2023
1 parent e2ee228 commit 84377c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Query/Scopes/Filters/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DoubleThreeDigital\Runway\Query\Scopes\Filters;

use DoubleThreeDigital\Runway\Runway;
use Statamic\Fields\Field;
use Statamic\Query\Scopes\Filters\Fields as BaseFieldsFilter;

class Fields extends BaseFieldsFilter
Expand All @@ -18,7 +19,13 @@ protected function getFields()
{
$resource = Runway::findResource($this->context['resource']);

return $resource->blueprint()->fields()->all()->filter->isFilterable();
return $resource->blueprint()->fields()->all()
->filter->isFilterable()
->reject(function (Field $field) use ($resource) {
return in_array($field->handle(), $resource->model()->getAppends(), true)
&& ! $resource->model()->hasSetMutator($field->handle())
&& ! $resource->model()->hasAttributeSetMutator($field->handle());
});
}

public function apply($query, $values)
Expand Down

0 comments on commit 84377c9

Please sign in to comment.