phpvms/app/Cron/Hourly/RemoveExpiredBids.php
2018-08-26 16:40:04 +00:00

32 lines
596 B
PHP

<?php
namespace App\Cron\Hourly;
use App\Events\CronHourly;
use App\Interfaces\Listener;
use App\Models\Bid;
use Carbon\Carbon;
/**
* Remove expired bids
*/
class RemoveExpiredBids extends Listener
{
/**
* Remove expired bids
*
* @param CronHourly $event
*
* @throws \Exception
*/
public function handle(CronHourly $event): void
{
if (setting('bids.expire_time') === 0) {
return;
}
$date = Carbon::now()->subHours(setting('bids.expire_time'));
Bid::whereDate('created_at', '<', $date)->delete();
}
}