You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using as subresource, you may define editable pivot fields:
684
+
When using as subresource, you may define editable pivot fields. Use the `withPivotFields` instead of the `withFields`:
644
685
645
686
> Only existing models can be attached, creating relatable models from the subresource is not supported.
646
687
@@ -655,14 +696,51 @@ $field->withPivotFields(static function (Request $request): array {
655
696
});
656
697
```
657
698
699
+
Sometimes you may want to attach the same model multiple times (maybe with different pivot values). To do so, call the `allowDuplicateRelations` method on the field:
700
+
701
+
```php
702
+
$field->allowDuplicateRelations();
703
+
```
704
+
705
+
When duplications are allowed, the relatable model query includes the already attached models as well, otherwise they are excluded from the query.
706
+
658
707
### HasMany
659
708
660
709
The `HasMany` field is typically a handler for a `Illuminate\Database\Eloquent\Relations\HasMany` relation:
0 commit comments