From 2cf12b01dccb0f807572957ebfe56c3364344c85 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 30 Nov 2022 20:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=AA=8C=E6=80=A7=20=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Transaction.php | 4 ++++ app/Models/User.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 87b3a31..cbfcfa5 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -23,6 +23,10 @@ class Transaction extends Model 'paid_at', ]; + protected $casts = [ + 'balance' => 'decimal:2', + ]; + protected $fillable = [ // 交易类型 'type', diff --git a/app/Models/User.php b/app/Models/User.php index b7344d7..64cd3e6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -113,7 +113,7 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', - 'balance' => 'float', + 'balance' => 'decimal:2', 'banned_at' => 'datetime', ]; @@ -125,9 +125,9 @@ protected static function boot() // balance 四舍五入 - if ($model->isDirty('balance')) { - $model->balance = round($model->balance, 2, PHP_ROUND_HALF_DOWN); - } + // if ($model->isDirty('balance')) { + // $model->balance = round($model->balance, 2, PHP_ROUND_HALF_DOWN); + // } if ($model->isDirty('banned_at')) { if ($model->banned_at) {