ldc-gen-game-web/app/Console/Commands/DeleteNotConfirmedUser.php

40 lines
827 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Console\Commands;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Console\Command;
class DeleteNotConfirmedUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'users:deletenc';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove users who have not confirmed their accounts within 24 hours of registration';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$users = User::where([['email_verified', 0], ['created_at', '<', Carbon::now()->subDay()]])->get();
2021-08-18 17:08:02 +02:00
foreach ($users as $user) {
$user->delete();
2021-08-18 17:08:02 +02:00
}
return 0;
}
}