File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
src/Illuminate/Database/Eloquent/Concerns
tests/Integration/Database Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -2101,7 +2101,7 @@ public function originalIsEquivalent($key)
2101
2101
}
2102
2102
2103
2103
return is_numeric ($ attribute ) && is_numeric ($ original )
2104
- && strcmp (( string ) $ attribute, ( string ) $ original ) === 0 ;
2104
+ && BigDecimal:: of ( $ attribute)-> isEqualTo ( $ original );
2105
2105
}
2106
2106
2107
2107
/**
Original file line number Diff line number Diff line change @@ -169,6 +169,33 @@ public function testDeviableCasts()
169
169
$ this ->assertSame ((new Decimal ('320.988 ' ))->getValue (), $ model ->price ->getValue ());
170
170
}
171
171
172
+ public function testDirtyOnCustomNumericCasts ()
173
+ {
174
+ $ model = new TestEloquentModelWithCustomCast ;
175
+ $ model ->price = '123.00 ' ;
176
+ $ model ->save ();
177
+
178
+ $ this ->assertFalse ($ model ->isDirty ());
179
+
180
+ $ model ->price = '123.00 ' ;
181
+ $ this ->assertFalse ($ model ->isDirty ('price ' ));
182
+
183
+ $ model ->price = '123.0 ' ;
184
+ $ this ->assertFalse ($ model ->isDirty ('price ' ));
185
+
186
+ $ model ->price = '123 ' ;
187
+ $ this ->assertFalse ($ model ->isDirty ('price ' ));
188
+
189
+ $ model ->price = '00123.00 ' ;
190
+ $ this ->assertFalse ($ model ->isDirty ('price ' ));
191
+
192
+ $ model ->price = '123.4000 ' ;
193
+ $ this ->assertTrue ($ model ->isDirty ('price ' ));
194
+
195
+ $ model ->price = '123.0004 ' ;
196
+ $ this ->assertTrue ($ model ->isDirty ('price ' ));
197
+ }
198
+
172
199
public function testSerializableCasts ()
173
200
{
174
201
$ model = new TestEloquentModelWithCustomCast ;
You can’t perform that action at this time.
0 commit comments