@@ -85,7 +85,7 @@ class EloquentHydrator extends AbstractHydrator implements HydratesRelatedInterf
85
85
*
86
86
* @var string[]
87
87
*/
88
- protected $ dates = [] ;
88
+ protected $ dates = NULL ;
89
89
90
90
/**
91
91
* Resource relationship keys that should be automatically hydrated.
@@ -163,7 +163,7 @@ protected function hydrateAttributes(StandardObjectInterface $attributes, $recor
163
163
}
164
164
165
165
if ($ attributes ->has ($ resourceKey )) {
166
- $ data [$ modelKey ] = $ this ->deserializeAttribute ($ attributes ->get ($ resourceKey ), $ resourceKey );
166
+ $ data [$ modelKey ] = $ this ->deserializeAttribute ($ record , $ attributes ->get ($ resourceKey ), $ resourceKey );
167
167
}
168
168
}
169
169
@@ -255,15 +255,16 @@ protected function keyForAttribute($resourceKey, Model $model)
255
255
/**
256
256
* Deserialize a value obtained from the resource's attributes.
257
257
*
258
+ * @param $record
258
259
* @param $value
259
260
* the value that the client provided.
260
261
* @param $resourceKey
261
262
* the attribute key for the value
262
263
* @return Carbon|null
263
264
*/
264
- protected function deserializeAttribute ($ value , $ resourceKey )
265
+ protected function deserializeAttribute ($ record , $ value , $ resourceKey )
265
266
{
266
- if ($ this ->isDateAttribute ($ resourceKey )) {
267
+ if ($ this ->isDateAttribute ($ record , $ resourceKey )) {
267
268
return $ this ->deserializeDate ($ value );
268
269
}
269
270
@@ -282,11 +283,17 @@ protected function deserializeDate($value)
282
283
/**
283
284
* Is this resource key a date attribute?
284
285
*
286
+ * @param $record
285
287
* @param $resourceKey
286
288
* @return bool
287
289
*/
288
- protected function isDateAttribute ($ resourceKey )
290
+ protected function isDateAttribute ($ record , $ resourceKey )
289
291
{
292
+ if (is_null ($ this ->dates ))
293
+ {
294
+ return in_array (Str::snake ($ resourceKey ), $ record ->getDates (), true );
295
+ }
296
+
290
297
return in_array ($ resourceKey , $ this ->dates , true );
291
298
}
292
299
0 commit comments