File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 5
5
use Jenssegers \Mongodb \Builder as QueryBuilder ;
6
6
7
7
use DateTime ;
8
+ use MongoId ;
8
9
use MongoDate ;
9
10
10
11
abstract class Model extends \Illuminate \Database \Eloquent \Model {
@@ -109,4 +110,31 @@ protected function newBaseQueryBuilder()
109
110
return new QueryBuilder ($ this ->getConnection ());
110
111
}
111
112
113
+ /**
114
+ * Set the array of model attributes. No checking is done.
115
+ *
116
+ * @param array $attributes
117
+ * @param bool $sync
118
+ * @return void
119
+ */
120
+ public function setRawAttributes (array $ attributes , $ sync = false )
121
+ {
122
+ foreach ($ attributes as $ key => &$ value )
123
+ {
124
+ // Convert MongoId
125
+ if ($ value instanceof MongoId)
126
+ {
127
+ $ value = (string ) $ value ;
128
+ }
129
+
130
+ // Convert MongoDate
131
+ else if ($ value instanceof MongoDate)
132
+ {
133
+ $ value = $ this ->asDateTime ($ value )->format ('Y-m-d H:i:s ' );
134
+ }
135
+ }
136
+
137
+ parent ::setRawAttributes ($ attributes , $ sync );
138
+ }
139
+
112
140
}
You can’t perform that action at this time.
0 commit comments