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(); + }); + } +};