-
Notifications
You must be signed in to change notification settings - Fork 1.5k
How can I update an Array of objects instead of object of objects? #2136
Unanswered
bobbylinux
asked this question in
Q&A
-
Hi, I'm trying to update a tree structure inside a document.
First of all I retrieve data from database with this expression:
$format = Format::findOrFail($formatId);
then I pass my structure called "sectionsOrder" into a dedicated variable and try to remove a specific element with a function.
$sectionsOrder = $format->sectionsOrder;
$sectionsOrder = $this->findAndRemoveSectionInSectionsOrder($sectionsOrder, $sectionId);
$format->sectionsOrder = $sectionsOrder;
$format->save();
The result of this is an ARRAY of Arrays. and finally I save all. Result I've found in my database "sectionsOrder" field an object of objects...
"sectionsOrder" : {
"1" : {
"id" : "5fb09b5f594f0000350074d7"
},
"2" : {
"id" : "5fb09b5f594f0000350074d8"
},
"3" : {
"id" : "5fb09b5f594f0000350074d9"
},
"4" : {
"id" : "5fb09b5f594f0000350074da"
},
"5" : {
"id" : "5fb09b5f594f0000350074db"
},
"6" : {
"id" : "5fb09b5f594f0000350074dc"
},
"7" : {
"id" : "5fb09b5f594f0000350074dd"
},
"8" : {
"id" : "5fb09b5f594f0000350074de"
},
"9" : {
"id" : "5fb09b5f594f0000350074df"
}
},
what is going wrong?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment