Skip to content

Commit 4bc7351

Browse files
committed
Update Model.php
1 parent 81a1910 commit 4bc7351

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/Eloquent/Model.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ abstract class Model extends BaseModel
7777
*/
7878
protected $parentRelation;
7979

80-
/**
81-
* Determine storing or retrieving data from database
82-
*
83-
* @var bool
84-
*/
85-
protected $storingOnDB = false;
86-
8780
/**
8881
* List of field names to unset from the document on save.
8982
*
@@ -218,7 +211,6 @@ protected function getAttributeFromArray($key)
218211
/** @inheritdoc */
219212
public function setAttribute($key, $value)
220213
{
221-
$this->storingOnDB = true;
222214
//Add casts
223215
if ($this->hasCast($key)) {
224216
$value = $this->castAttribute($key, $value);
@@ -255,11 +247,8 @@ protected function asDecimal($value, $decimals)
255247
{
256248
try {
257249
$value = (string) BigDecimal::of((string)$value)->toScale((int)$decimals, RoundingMode::HALF_UP);
258-
if ($this->storingOnDB) {
259-
$value = new Decimal128($value);
260-
}
261250

262-
return $value;
251+
return new Decimal128($value);
263252
} catch (BrickMathException $e) {
264253
throw new MathException('Unable to cast value to a decimal.', previous: $e);
265254
}
@@ -268,7 +257,7 @@ protected function asDecimal($value, $decimals)
268257
/** @inheritdoc */
269258
public function fromJson($value, $asObject = false)
270259
{
271-
if ($this->storingOnDB && !is_string($value)) {
260+
if (!is_string($value)) {
272261
$value = Json::encode($value ?? '');
273262
}
274263
return Json::decode($value ?? '', ! $asObject);

0 commit comments

Comments
 (0)