This commit is contained in:
EwelinaLasowy
2022-02-11 13:02:35 +01:00
parent d026d41715
commit a0b64e6cb3
9 changed files with 500 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Toby\Domain;
use Illuminate\Support\Collection;
use Toby\Domain\Enums\Role;
use Toby\Domain\Notifications\VacationRequestNotification;
use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\VacationRequest;
class VacationRequestNotificationSender
{
public function sendVacationRequestNotification(VacationRequest $vacationRequest): void
{
foreach ($this->getUsersForNotifications() as $user) {
$user->notify(new VacationRequestNotification($user, $vacationRequest));
}
$vacationRequest->user->notify(new VacationRequestNotification($vacationRequest->user, $vacationRequest));
}
protected function getUsersForNotifications(): Collection
{
return User::query()
->where("role", Role::TECHNICAL_APPROVER)
->orWhere("role", Role::ADMINISTRATIVE_APPROVER)
->get();
}
}