2018-08-25 01:07:14 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Cron\Hourly;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Listener;
|
2019-07-16 03:51:35 +08:00
|
|
|
use App\Events\CronHourly;
|
2018-08-25 01:07:14 +08:00
|
|
|
use App\Models\Bid;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove expired bids
|
|
|
|
*/
|
|
|
|
class RemoveExpiredBids extends Listener
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Remove expired bids
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-08-25 01:07:14 +08:00
|
|
|
* @param CronHourly $event
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-08-25 01:07:14 +08:00
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function handle(CronHourly $event): void
|
|
|
|
{
|
2018-08-27 00:40:04 +08:00
|
|
|
if (setting('bids.expire_time') === 0) {
|
2018-08-25 01:07:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-13 21:25:38 +08:00
|
|
|
$date = Carbon::now('UTC')->subHours(setting('bids.expire_time'));
|
2021-04-10 07:15:22 +08:00
|
|
|
Bid::where('created_at', '<', $date)->delete();
|
2018-08-25 01:07:14 +08:00
|
|
|
}
|
2018-08-25 01:14:35 +08:00
|
|
|
}
|