File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/Jenssegers/Mongodb/Eloquent Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -165,10 +165,16 @@ protected function getAttributeFromArray($key)
165
165
public function setAttribute ($ key , $ value )
166
166
{
167
167
// Convert _id to ObjectID.
168
- if (is_string ($ value ) && ( $ key === '_id ' || $ this ->isObjectId ($ key) )) {
168
+ if (( is_string ($ value ) && $ key === '_id ' ) || $ this ->isObjectId ($ key )) {
169
169
$ builder = $ this ->newBaseQueryBuilder ();
170
170
171
- $ value = $ builder ->convertKey ($ value );
171
+ if (is_array ($ value )) {
172
+ foreach ($ value as &$ val ) {
173
+ $ val = $ builder ->convertKey ($ val );
174
+ }
175
+ } else {
176
+ $ value = $ builder ->convertKey ($ value );
177
+ }
172
178
} // Support keys in dot notation.
173
179
elseif (Str::contains ($ key , '. ' )) {
174
180
if (in_array ($ key , $ this ->getDates ()) && $ value ) {
@@ -491,6 +497,14 @@ protected function castAttribute($key, $value)
491
497
}
492
498
493
499
if ($ this ->getCastType ($ key ) === 'objectid ' ) {
500
+ if (is_array ($ value )) {
501
+ foreach ($ value as &$ val ) {
502
+ $ val = (string ) $ val ;
503
+ }
504
+
505
+ return $ value ;
506
+ }
507
+
494
508
return (string ) $ value ;
495
509
}
496
510
You can’t perform that action at this time.
0 commit comments