39 lines
868 B
PHP
39 lines
868 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Customer;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Console\Command;
|
|
|
|
class DeleteNotConfirmedCustomer extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'customers:deletenc';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Remove customers who have not confirmed their accounts within 24 hours of registration';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function handle()
|
|
{
|
|
$customers = Customer::where([['email_verified', false], ['created_at', '<', Carbon::now()->subDay()]])->get();
|
|
foreach ($customers as $customer) {
|
|
$customers->delete();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|