改进 价格计算类型

This commit is contained in:
iVampireSP.com 2023-01-14 18:11:17 +08:00
parent 1fda7d38d0
commit 08f2fc2306
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
5 changed files with 72 additions and 4 deletions

View File

@ -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()

View File

@ -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',
];

View File

@ -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')) {

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('hosts', function (Blueprint $table) {
// 将 price 和 managed_price 改成 decimal
$table->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();
});
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->decimal('balance')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->decimal('balance', 10)->change();
});
}
};