6c3992e781
* Fix for Hourly Cron We should be using whereTime instead of whereDate https://laravel.com/docs/8.x/queries#additional-where-clauses `The whereDate method may be used to compare a column's value against a date` * Fix for RemoveExpiredBids I used where to do check 'cause people may set 48 hours to remove a bid, thus neither whereDate nor whereTime will give a correct results. * Fix for DeletePireps I used where to do check 'cause people may set 48 hours to delete cancelled or rejected pireps, thus neither whereDate nor whereTime will give a correct results.
32 lines
591 B
PHP
32 lines
591 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::where('created_at', '<', $date)->delete();
|
|
}
|
|
}
|