Replies: 1 comment
-
Would love to see if there are any alternative ways to not calling the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Assume there's a model with a
belongsToMany
relationship. The relationship is using a custom intermediate table class that extendsSortablePivot
. TheSortablePivot
is as follows:It often occurs that this kind of sortable relationships are being re-sorted. No new items are being added to the pivot table, just re-sorting based on user input. How would one approach this?
Currently I'm using the following method:
I'd love to get rid of the
$layout->blocks()->detach();
while keeping the code as close as possible to what one would expect from a Laravel code base.Ideally
$layout->blocks()->sync($this->validated()['blocks'] ?? []);
would "just work". However, the intention of thesync()
method is syncing the ID's and not updating the pivot attributes, although inserting pivot attributes is supported. Out of the box, thesync()
method does not mutate existing records.Beta Was this translation helpful? Give feedback.
All reactions