* change layout * change layout * #22 - wip * wip * wip * #22 - wip * #22 - wip * #22 - wip * #22 - wip * #22 - fix * #22 - wip * #22 - added some tests * #22 - wip * #22 - wip * #22 - fix * #41 - wip * #22 - wip * #22 - wip * #22 - wip * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #41 - wip * #41 - wip * #49 - laravel 9 * #41 - wip * #41 - fix * #41 - fix * Apply suggestions from code review Co-authored-by: Jacek Sawoszczuk <jacek.sawoszczuk@gmail.com> * #41 - cr fix * #41 - cr fix Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> Co-authored-by: Jacek Sawoszczuk <jacek.sawoszczuk@gmail.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Events\VacationRequestApproved;
|
||||
use Toby\Domain\Notifications\VacationRequestApprovedNotification;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class SendApprovedVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestApproved $event): void
|
||||
{
|
||||
foreach ($this->getUsersForNotifications() as $user) {
|
||||
$user->notify(new VacationRequestApprovedNotification($event->vacationRequest, $user));
|
||||
}
|
||||
|
||||
$event->vacationRequest->user->notify(new VacationRequestApprovedNotification($event->vacationRequest, $event->vacationRequest->user));
|
||||
}
|
||||
|
||||
protected function getUsersForNotifications(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->whereIn("role", [Role::TechnicalApprover, Role::AdministrativeApprover])
|
||||
->get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Events\VacationRequestCancelled;
|
||||
use Toby\Domain\Notifications\VacationRequestCancelledNotification;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class SendCancelledVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestCancelled $event): void
|
||||
{
|
||||
foreach ($this->getUsersForNotifications() as $user) {
|
||||
$user->notify(new VacationRequestCancelledNotification($event->vacationRequest, $user));
|
||||
}
|
||||
|
||||
$event->vacationRequest->user->notify(new VacationRequestCancelledNotification($event->vacationRequest, $event->vacationRequest->user));
|
||||
}
|
||||
|
||||
protected function getUsersForNotifications(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->whereIn("role", [Role::TechnicalApprover, Role::AdministrativeApprover])
|
||||
->get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Toby\Domain\Events\VacationRequestCreated;
|
||||
use Toby\Domain\Notifications\VacationRequestCreatedNotification;
|
||||
|
||||
class SendCreatedVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestCreated $event): void
|
||||
{
|
||||
$event->vacationRequest->user->notify(new VacationRequestCreatedNotification($event->vacationRequest));
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Events\VacationRequestRejected;
|
||||
use Toby\Domain\Notifications\VacationRequestRejectedNotification;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class SendRejectedVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestRejected $event): void
|
||||
{
|
||||
foreach ($this->getUsersForNotifications() as $user) {
|
||||
$user->notify(new VacationRequestRejectedNotification($event->vacationRequest, $user));
|
||||
}
|
||||
|
||||
$event->vacationRequest->user->notify(new VacationRequestRejectedNotification($event->vacationRequest, $event->vacationRequest->user));
|
||||
}
|
||||
|
||||
protected function getUsersForNotifications(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->whereIn("role", [Role::TechnicalApprover, Role::AdministrativeApprover])
|
||||
->get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Events\VacationRequestWaitsForAdminApproval;
|
||||
use Toby\Domain\Notifications\VacationRequestWaitsForAdminApprovalNotification;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class SendWaitedForAdministrativeVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestWaitsForAdminApproval $event): void
|
||||
{
|
||||
foreach ($this->getUsersForNotifications() as $user) {
|
||||
$user->notify(new VacationRequestWaitsForAdminApprovalNotification($event->vacationRequest, $user));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUsersForNotifications(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->where("role", [Role::AdministrativeApprover])
|
||||
->get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Listeners;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Domain\Events\VacationRequestWaitsForTechApproval;
|
||||
use Toby\Domain\Notifications\VacationRequestWaitsForTechApprovalNotification;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class SendWaitedForTechnicalVacationRequestNotification
|
||||
{
|
||||
public function __construct(
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(VacationRequestWaitsForTechApproval $event): void
|
||||
{
|
||||
foreach ($this->getUsersForNotifications() as $user) {
|
||||
$user->notify(new VacationRequestWaitsForTechApprovalNotification($event->vacationRequest, $user));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUsersForNotifications(): Collection
|
||||
{
|
||||
return User::query()
|
||||
->where("role", [Role::TechnicalApprover])
|
||||
->get();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user