From 8542b02493c8759cd9b75d4e3041877ceebd5265 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 8 Mar 2023 01:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2023_03_07_194636_add_trial_ends_at_to_hosts_table.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php b/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php index d586733..523c644 100644 --- a/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php +++ b/database/migrations/2023_03_07_194636_add_trial_ends_at_to_hosts_table.php @@ -29,11 +29,15 @@ public function up(): void $table->timestamp('expired_at')->nullable()->after('last_paid_at'); }); + $hosts = Host::all(); + $count = $hosts->count(); // 为已有的主机设置默认值 - Host::all()->each(function (Host $host) { + Host::all()->each(function (Host $host) use (&$count) { + echo "Migrating {$host->id} ({$host->name})... {$count} left".PHP_EOL; + $host->day_at = $host->created_at->day; - $host->save(); + $host->saveQuietly(); }); }