From 08f2fc2306255eb8f617e78f20c05edb6ba71054 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sat, 14 Jan 2023 18:11:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Host.php | 4 +-- app/Models/User.php | 2 +- ...8_30_081930_add_balance_to_users_table.php | 2 +- ...1_14_180605_change_type_to_hosts_table.php | 36 +++++++++++++++++++ ...22_change_decimal_total_to_users_table.php | 32 +++++++++++++++++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2023_01_14_180605_change_type_to_hosts_table.php create mode 100644 database/migrations/2023_01_14_181022_change_decimal_total_to_users_table.php diff --git a/app/Models/Host.php b/app/Models/Host.php index 74446ab..364b2a8 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -32,8 +32,8 @@ class Host extends Model protected $casts = [ // 'configuration' => 'array', 'suspended_at' => 'datetime', - 'price' => 'decimal:2', - 'managed_price' => 'decimal:2', + 'price' => 'decimal', + 'managed_price' => 'decimal', ]; protected static function boot() diff --git a/app/Models/User.php b/app/Models/User.php index b9dd53f..5995676 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -39,7 +39,7 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', - 'balance' => 'decimal:2', + 'balance' => 'decimal', 'banned_at' => 'datetime', 'birthday_at' => 'date', ]; diff --git a/database/migrations/2022_08_30_081930_add_balance_to_users_table.php b/database/migrations/2022_08_30_081930_add_balance_to_users_table.php index 9ffa7b5..c4fcff0 100644 --- a/database/migrations/2022_08_30_081930_add_balance_to_users_table.php +++ b/database/migrations/2022_08_30_081930_add_balance_to_users_table.php @@ -14,7 +14,7 @@ public function up(): void { Schema::table('users', function (Blueprint $table) { // - $table->decimal('balance', 10)->default(0)->after('password'); + $table->decimal('balance')->default(0)->after('password'); // drop column if exists if (Schema::hasColumn('users', 'drops')) { diff --git a/database/migrations/2023_01_14_180605_change_type_to_hosts_table.php b/database/migrations/2023_01_14_180605_change_type_to_hosts_table.php new file mode 100644 index 0000000..10f2f71 --- /dev/null +++ b/database/migrations/2023_01_14_180605_change_type_to_hosts_table.php @@ -0,0 +1,36 @@ +decimal('price')->change(); + $table->decimal('managed_price')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('hosts', function (Blueprint $table) { + // 回滚 + $table->unsignedDouble('price', 10)->change(); + $table->unsignedDouble('managed_price', 10)->change(); + }); + } +}; diff --git a/database/migrations/2023_01_14_181022_change_decimal_total_to_users_table.php b/database/migrations/2023_01_14_181022_change_decimal_total_to_users_table.php new file mode 100644 index 0000000..577ad75 --- /dev/null +++ b/database/migrations/2023_01_14_181022_change_decimal_total_to_users_table.php @@ -0,0 +1,32 @@ +decimal('balance')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->decimal('balance', 10)->change(); + }); + } +};