Вход Регистрация
Файл: app/Console/Commands/DeletePending.php
Строк: 45
<?php

namespace AppConsoleCommands;

use 
AppModelsUser;
use 
IlluminateConsoleCommand;
use 
SymfonyComponentConsoleCommandCommand as SymfonyCommand;

class 
DeletePending extends Command
{
    
/**
     * The name and signature of the console command.
     */
    
protected $signature 'delete:pending';

    
/**
     * The console command description.
     */
    
protected $description 'Delete pending user';

    
/**
     * Удаляет не активированные аккаунты
     */
    
public function handle(): int
    
{
        if (
setting('regkeys')) {
            
$users User::query()
                ->
where('level'User::PENDED)
                ->
where('created_at''<'now()->subDay())
                ->
get();

            foreach (
$users as $user) {
                
$user->delete();
            }
        } else {
            
User::query()
                ->
where('level'User::PENDED)
                ->
update([
                    
'level' => User::USER,
                ]);
        }

        
$this->info('Pending user successfully deleted.');

        return 
SymfonyCommand::SUCCESS;
    }
}
Онлайн: 0
Реклама