diff --git a/app/Casts/Price.php b/app/Casts/Price.php index 91c87fe1..adb848d8 100644 --- a/app/Casts/Price.php +++ b/app/Casts/Price.php @@ -17,6 +17,10 @@ class Price implements CastsAttributes */ public function get($model, string $key, $value, array $attributes) { + if ((string) $value === '') { + return null; + } + return bcdiv($value, 100, 2); } @@ -31,6 +35,10 @@ class Price implements CastsAttributes */ public function set($model, string $key, $value, array $attributes) { + if ((string) $value === '') { + return null; + } + return (int) bcmul($value, 100); } }