File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed
src/Jenssegers/Mongodb/Relations Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 66use Illuminate \Database \Eloquent \Model ;
77use Illuminate \Pagination \LengthAwarePaginator ;
88use Illuminate \Pagination \Paginator ;
9- use Illuminate \Support \Arr ;
109use MongoDB \BSON \ObjectID ;
1110
1211class EmbedsMany extends EmbedsOneOrMany
@@ -79,8 +78,7 @@ public function performUpdate(Model $model)
7978 // Get the correct foreign key value.
8079 $ foreignKey = $ this ->getForeignKeyValue ($ model );
8180
82- // Use array dot notation for better update behavior.
83- $ values = Arr::dot ($ model ->getDirty (), $ this ->localKey . '.$. ' );
81+ $ values = $ this ->getUpdateValues ($ model ->getDirty (), $ this ->localKey . '.$. ' );
8482
8583 // Update document in database.
8684 $ result = $ this ->getBaseQuery ()->where ($ this ->localKey . '. ' . $ model ->getKeyName (), $ foreignKey )
Original file line number Diff line number Diff line change 33namespace Jenssegers \Mongodb \Relations ;
44
55use Illuminate \Database \Eloquent \Model ;
6- use Illuminate \Support \Arr ;
76use MongoDB \BSON \ObjectID ;
87
98class EmbedsOne extends EmbedsOneOrMany
@@ -71,8 +70,7 @@ public function performUpdate(Model $model)
7170 return $ this ->parent ->save ();
7271 }
7372
74- // Use array dot notation for better update behavior.
75- $ values = Arr::dot ($ model ->getDirty (), $ this ->localKey . '. ' );
73+ $ values = $ this ->getUpdateValues ($ model ->getDirty (), $ this ->localKey . '. ' );
7674
7775 $ result = $ this ->getBaseQuery ()->update ($ values );
7876
Original file line number Diff line number Diff line change @@ -375,4 +375,22 @@ protected function getParentKey()
375375 {
376376 return $ this ->parent ->getKey ();
377377 }
378+
379+ /**
380+ * Return update values
381+ *
382+ * @param $array
383+ * @param string $prepend
384+ * @return array
385+ */
386+ public static function getUpdateValues ($ array , $ prepend = '' )
387+ {
388+ $ results = [];
389+
390+ foreach ($ array as $ key => $ value ) {
391+ $ results [$ prepend .$ key ] = $ value ;
392+ }
393+
394+ return $ results ;
395+ }
378396}
You can’t perform that action at this time.
0 commit comments