增加 删除没有验证的用户

This commit is contained in:
iVampireSP.com 2023-02-20 00:57:33 +08:00
parent 6c4b06a7a7
commit 512962b19b
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,7 @@
use App\Jobs\Module\SendModuleEarningsJob; use App\Jobs\Module\SendModuleEarningsJob;
use App\Jobs\User\CheckAndChargeBalanceJob; use App\Jobs\User\CheckAndChargeBalanceJob;
use App\Jobs\User\ClearTasksJob; use App\Jobs\User\ClearTasksJob;
use App\Jobs\User\DeleteUnverifiedUserJob;
use App\Jobs\User\RollbackUserTempGroupJob; use App\Jobs\User\RollbackUserTempGroupJob;
use App\Jobs\User\SetBirthdayGroupJob; use App\Jobs\User\SetBirthdayGroupJob;
use App\Jobs\WorkOrder\AutoCloseWorkOrderJob; use App\Jobs\WorkOrder\AutoCloseWorkOrderJob;
@ -60,6 +61,9 @@ protected function schedule(Schedule $schedule): void
// 设置生日用户组 // 设置生日用户组
$schedule->job(new SetBirthdayGroupJob())->dailyAt('00:00')->onOneServer()->name('设置生日用户组'); $schedule->job(new SetBirthdayGroupJob())->dailyAt('00:00')->onOneServer()->name('设置生日用户组');
// 删除注册超过 3 天未验证邮箱的用户
$schedule->job(new DeleteUnverifiedUserJob())->daily()->onOneServer()->name('删除注册超过 3 天未验证邮箱的用户');
} }
/** /**

View File

@ -0,0 +1,21 @@
<?php
namespace App\Jobs\User;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class DeleteUnverifiedUserJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle(): void
{
// 删除注册时间超过 3 天的未验证邮箱用户。
User::where('email_verified_at', null)->where('created_at', '<', now()->subDays(3))->delete();
}
}