This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/Console/Command/PremiumPurgeCommand.php

47 lines
984 B
PHP

<?php
/**
* Holds the purge premium command controller.
* @package Sakura
*/
namespace Sakura\Console\Command;
use CLIFramework\Command;
use Sakura\DB;
use Sakura\User;
/**
* Starts up a development server.
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class PremiumPurgeCommand extends Command
{
/**
* A quick description of this command.
* @return string.
*/
public function brief(): string
{
return 'Purge expired premium.';
}
/**
* Purge expired premium subs.
*/
public function execute(): void
{
$expiredPremium = DB::table('premium')
->where('premium_expire', '<', time())
->get(['user_id']);
foreach ($expiredPremium as $premium) {
DB::table('premium')
->where('user_id', $premium->user_id)
->delete();
User::construct($premium->user_id)
->isPremium();
}
}
}