Cronjobs implemented
This commit is contained in:
21
app/Tasks/CloseEvent.php
Normal file
21
app/Tasks/CloseEvent.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tasks;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Repositories\EventRepository;
|
||||
|
||||
class CloseEvent implements CronTask {
|
||||
public function handle(): void
|
||||
{
|
||||
$now = now();
|
||||
$eventRepository = new EventRepository();
|
||||
/** @var Event $event */
|
||||
foreach ($eventRepository->getAvailable(false) as $event) {
|
||||
if ($event->registration_final_end < $now ) {
|
||||
$event->registration_allowed = false;
|
||||
$event->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user