phpvms/app/Cron/Hourly/RemoveExpiredBids.php
2019-07-15 15:51:35 -04:00

32 lines
595 B
PHP

<?php
namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly;
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();
}
}