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

48 lines
970 B
PHP
Raw Normal View History

2016-09-13 13:39:11 +00:00
<?php
/**
* Holds the purge premium command controller.
* @package Sakura
*/
namespace Sakura\Console\Command;
use CLIFramework\Command;
use Sakura\DB;
2016-09-16 19:06:09 +00:00
use Sakura\User;
2016-09-13 13:39:11 +00:00
/**
* 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()
{
return 'Purge expired premium.';
}
/**
* Purge expired premium subs.
*/
public function execute()
{
$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();
}
}
}