Cronjobs implemented
This commit is contained in:
21
app/Tasks/CloseCostUnit.php
Normal file
21
app/Tasks/CloseCostUnit.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tasks;
|
||||
|
||||
use App\Models\CostUnit;
|
||||
use App\Repositories\CostUnitRepository;
|
||||
|
||||
class CloseCostUnit implements CronTask {
|
||||
public function handle(): void
|
||||
{
|
||||
$now = now();
|
||||
$costUnitRepository = new CostUnitRepository();
|
||||
/** @var CostUnit $costUnit */
|
||||
foreach ($costUnitRepository->getCurrentEvents() as $costUnit) {
|
||||
if (\DateTime::createFromFormat('Y-m-d', $costUnit->billing_deadline) < $now ) {
|
||||
$costUnit->allow_new = false;
|
||||
$costUnit->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user