File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -355,6 +355,29 @@ public function attributesToArray()
355
355
return $ attributes ;
356
356
}
357
357
358
+ /**
359
+ * Determine if the new and old values for a given key are numerically equivalent.
360
+ *
361
+ * @param string $key
362
+ * @return bool
363
+ */
364
+ protected function originalIsNumericallyEquivalent ($ key )
365
+ {
366
+ $ current = $ this ->attributes [$ key ];
367
+
368
+ $ original = $ this ->original [$ key ];
369
+
370
+ // Date comparison.
371
+ if (in_array ($ key , $ this ->getDates ()))
372
+ {
373
+ $ current = $ current instanceof MongoDate ? $ this ->asDateTime ($ current ) : $ current ;
374
+ $ original = $ original instanceof MongoDate ? $ this ->asDateTime ($ original ) : $ original ;
375
+ return $ current == $ original ;
376
+ }
377
+
378
+ return parent ::originalIsNumericallyEquivalent ($ key );
379
+ }
380
+
358
381
/**
359
382
* Remove one or more fields.
360
383
*
Original file line number Diff line number Diff line change @@ -490,4 +490,14 @@ public function testDotNotation()
490
490
$ this ->assertEquals ('Paris ' , $ user ->{'address.city ' });
491
491
}
492
492
493
+ public function testGetDirtyDates ()
494
+ {
495
+ $ user = new User ();
496
+ $ user ->setRawAttributes (['name ' => 'John Doe ' , 'birthday ' => new DateTime ('19 august 1989 ' )], true );
497
+ $ this ->assertEmpty ($ user ->getDirty ());
498
+
499
+ $ user ->birthday = new DateTime ('19 august 1989 ' );
500
+ $ this ->assertEmpty ($ user ->getDirty ());
501
+ }
502
+
493
503
}
You can’t perform that action at this time.
0 commit comments