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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
app/Tasks/NotifyTeam.php
Normal file
41
app/Tasks/NotifyTeam.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tasks;
|
||||
|
||||
use App\Domains\Invoice\Actions\UploadInvoice\UploadInvoiceCommand;
|
||||
use App\Domains\Invoice\Actions\UploadInvoice\UploadInvoiceRequest;
|
||||
use App\Mail\EventReportMails\InformLocalGroupMail;
|
||||
use App\Mail\ParticipantParticipationMails\ParticipantSignOffMail;
|
||||
use App\Models\Event;
|
||||
use App\Models\Tenant;
|
||||
use App\Repositories\EventRepository;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class NotifyTeam implements CronTask {
|
||||
public function handle(): void
|
||||
{
|
||||
if (date('w') !== 0) {
|
||||
// return;
|
||||
}
|
||||
|
||||
$eventRepository = new EventRepository();
|
||||
/** @var Event $event */
|
||||
foreach ($eventRepository->getAvailable(false) as $event) {
|
||||
foreach (Tenant::all() as $tenant) {
|
||||
$participants = $event->participants()->where('local_group', $tenant->slug)->whereNull('unregistered_at')->get();
|
||||
}
|
||||
|
||||
if ($participants->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Mail::to($tenant->email)->send(new InformLocalGroupMail(
|
||||
event: $event,
|
||||
participants: $participants,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user