Skip to content

Commit a903f54

Browse files
committed
fix: hide hidden pivots
1 parent f7942c6 commit a903f54

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Fields/BelongsToMany.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Binaryk\LaravelRestify\Contracts\RestifySearchable;
66
use Binaryk\LaravelRestify\Fields\Concerns\Attachable;
7+
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
78
use Binaryk\LaravelRestify\Repositories\PivotsCollection;
89
use Binaryk\LaravelRestify\Repositories\Repository;
910
use Closure;
@@ -55,6 +56,7 @@ public function resolve($repository, $attribute = null)
5556
->withPivots(
5657
PivotsCollection::make($this->pivotFields)
5758
->map(fn (Field $field) => clone $field)
59+
->filter(fn (Field $field) => !$field->isHidden(app(RestifyRequest::class)))
5860
->resolveFromPivot($item->pivot)
5961
)
6062
->eager($this);

0 commit comments

Comments
 (0)