改进 价格计算类型
This commit is contained in:
parent
1fda7d38d0
commit
08f2fc2306
@ -32,8 +32,8 @@ class Host extends Model
|
|||||||
protected $casts = [
|
protected $casts = [
|
||||||
// 'configuration' => 'array',
|
// 'configuration' => 'array',
|
||||||
'suspended_at' => 'datetime',
|
'suspended_at' => 'datetime',
|
||||||
'price' => 'decimal:2',
|
'price' => 'decimal',
|
||||||
'managed_price' => 'decimal:2',
|
'managed_price' => 'decimal',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
|
@ -39,7 +39,7 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
'balance' => 'decimal:2',
|
'balance' => 'decimal',
|
||||||
'banned_at' => 'datetime',
|
'banned_at' => 'datetime',
|
||||||
'birthday_at' => 'date',
|
'birthday_at' => 'date',
|
||||||
];
|
];
|
||||||
|
@ -14,7 +14,7 @@ public function up(): void
|
|||||||
{
|
{
|
||||||
Schema::table('users', function (Blueprint $table) {
|
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
|
// drop column if exists
|
||||||
if (Schema::hasColumn('users', 'drops')) {
|
if (Schema::hasColumn('users', 'drops')) {
|
||||||
|
@ -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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user