@@ -77,13 +77,6 @@ abstract class Model extends BaseModel
77
77
*/
78
78
protected $ parentRelation ;
79
79
80
- /**
81
- * Determine storing or retrieving data from database
82
- *
83
- * @var bool
84
- */
85
- protected $ storingOnDB = false ;
86
-
87
80
/**
88
81
* List of field names to unset from the document on save.
89
82
*
@@ -218,7 +211,6 @@ protected function getAttributeFromArray($key)
218
211
/** @inheritdoc */
219
212
public function setAttribute ($ key , $ value )
220
213
{
221
- $ this ->storingOnDB = true ;
222
214
//Add casts
223
215
if ($ this ->hasCast ($ key )) {
224
216
$ value = $ this ->castAttribute ($ key , $ value );
@@ -255,11 +247,8 @@ protected function asDecimal($value, $decimals)
255
247
{
256
248
try {
257
249
$ value = (string ) BigDecimal::of ((string )$ value )->toScale ((int )$ decimals , RoundingMode::HALF_UP );
258
- if ($ this ->storingOnDB ) {
259
- $ value = new Decimal128 ($ value );
260
- }
261
250
262
- return $ value ;
251
+ return new Decimal128 ( $ value) ;
263
252
} catch (BrickMathException $ e ) {
264
253
throw new MathException ('Unable to cast value to a decimal. ' , previous: $ e );
265
254
}
@@ -268,7 +257,7 @@ protected function asDecimal($value, $decimals)
268
257
/** @inheritdoc */
269
258
public function fromJson ($ value , $ asObject = false )
270
259
{
271
- if ($ this -> storingOnDB && !is_string ($ value )) {
260
+ if (!is_string ($ value )) {
272
261
$ value = Json::encode ($ value ?? '' );
273
262
}
274
263
return Json::decode ($ value ?? '' , ! $ asObject );
0 commit comments