39 lines
827 B
PHP
39 lines
827 B
PHP
<?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();
|
|
foreach ($users as $user) {
|
|
$user->delete();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|