Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I update an Array of objects instead of object of objects? #2136

Unanswered
bobbylinux asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /