diff --git a/src/Laravel/Fields/Relationships/BelongsToMany.php b/src/Laravel/Fields/Relationships/BelongsToMany.php index 180927b15..37ddd73a1 100644 --- a/src/Laravel/Fields/Relationships/BelongsToMany.php +++ b/src/Laravel/Fields/Relationships/BelongsToMany.php @@ -213,7 +213,7 @@ public function getPreparedFields(): FieldsCollection { return $this->getFields()->prepareAttributes()->prepareReindex( parent: $this, - before: fn(self $parent, Field $field): FormElement => (clone $field) + before: fn (self $parent, Field $field): FormElement => (clone $field) ->setColumn("{$this->getPivotAs()}.{$field->getColumn()}") ->setNameAttribute($field->getColumn()) ->setAttribute('class', 'pivotField') @@ -296,7 +296,7 @@ protected function resolveValue(): mixed return $value ->setRelations([ - $this->getPivotAs() => $data[$value->getKey()] ?? [] + $this->getPivotAs() => $data[$value->getKey()] ?? [], ]) ->setAttribute($identityField->getColumn(), $data[$value->getKey()][$identityField->getColumn()] ?? false); } @@ -413,7 +413,7 @@ public function getCheckedKeys(): Collection } return $requestValues - ->filter(static fn(array $value) => $value['_checked']) + ->filter(static fn (array $value) => $value['_checked']) ->keys(); } diff --git a/tests/Feature/Fields/Relationships/BelongsToManyFieldTest.php b/tests/Feature/Fields/Relationships/BelongsToManyFieldTest.php index 0f3659565..e86a85851 100644 --- a/tests/Feature/Fields/Relationships/BelongsToManyFieldTest.php +++ b/tests/Feature/Fields/Relationships/BelongsToManyFieldTest.php @@ -38,13 +38,13 @@ function testBelongsToManyValue(TestResource $resource, Item $item, array $data, ?array $expectedData = null, ?array $pivotData = null) { $mapper = static function (array $d, array $p = []) { - return collect($d)->mapWithKeys(fn($v, $k) => [$k => [ + return collect($d)->mapWithKeys(fn ($v, $k) => [$k => [ '_checked' => 1, - ...$p[$k] ?? [] + ...$p[$k] ?? [], ]])->toArray(); }; - if(!is_null($pivotData)) { + if(! is_null($pivotData)) { $data = $mapper($data, $pivotData); } @@ -59,12 +59,12 @@ function testBelongsToManyValue(TestResource $resource, Item $item, array $data, $real = $item->categories->pluck('id', 'id')->toArray(); - if(!is_null($pivotData)) { + if(! is_null($pivotData)) { $pivot = $item->categories->mapWithKeys(fn ($c) => [ $c->id => array_filter([ 'pivot_1' => $c->pivot->pivot_1, 'pivot_2' => $c->pivot->pivot_2, - ]) + ]), ])->toArray(); $real = $mapper($real, $pivot);