#41 - cr fix
This commit is contained in:
parent
64c99f4632
commit
d04c61481c
@ -15,6 +15,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("j F Y"));
|
Carbon::macro("toDisplayString", fn() => $this->translatedFormat("j F Y"));
|
||||||
|
Carbon::macro("toDisplayDate", fn() => $this->translatedFormat("d.m.Y"));
|
||||||
|
|
||||||
$selectedYearPeriodScope = $this->app->make(SelectedYearPeriodScope::class);
|
$selectedYearPeriodScope = $this->app->make(SelectedYearPeriodScope::class);
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ use Toby\Domain\Events\VacationRequestCancelled;
|
|||||||
use Toby\Domain\Events\VacationRequestCreated;
|
use Toby\Domain\Events\VacationRequestCreated;
|
||||||
use Toby\Domain\Events\VacationRequestRejected;
|
use Toby\Domain\Events\VacationRequestRejected;
|
||||||
use Toby\Domain\Events\VacationRequestStateChanged;
|
use Toby\Domain\Events\VacationRequestStateChanged;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForAdministrative;
|
use Toby\Domain\Events\VacationRequestWaitsForAdminApproval;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForTechnical;
|
use Toby\Domain\Events\VacationRequestWaitsForTechApproval;
|
||||||
use Toby\Domain\Listeners\CreateVacationRequestActivity;
|
use Toby\Domain\Listeners\CreateVacationRequestActivity;
|
||||||
use Toby\Domain\Listeners\HandleAcceptedByAdministrativeVacationRequest;
|
use Toby\Domain\Listeners\HandleAcceptedByAdministrativeVacationRequest;
|
||||||
use Toby\Domain\Listeners\HandleAcceptedByTechnicalVacationRequest;
|
use Toby\Domain\Listeners\HandleAcceptedByTechnicalVacationRequest;
|
||||||
@ -37,7 +37,7 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
VacationRequestApproved::class => [HandleApprovedVacationRequest::class, SendApprovedVacationRequestNotification::class],
|
VacationRequestApproved::class => [HandleApprovedVacationRequest::class, SendApprovedVacationRequestNotification::class],
|
||||||
VacationRequestRejected::class => [SendRejectedVacationRequestNotification::class],
|
VacationRequestRejected::class => [SendRejectedVacationRequestNotification::class],
|
||||||
VacationRequestCancelled::class => [HandleCancelledVacationRequest::class, SendCancelledVacationRequestNotification::class],
|
VacationRequestCancelled::class => [HandleCancelledVacationRequest::class, SendCancelledVacationRequestNotification::class],
|
||||||
VacationRequestWaitedForTechnical::class => [SendWaitedForTechnicalVacationRequestNotification::class],
|
VacationRequestWaitsForTechApproval::class => [SendWaitedForTechnicalVacationRequestNotification::class],
|
||||||
VacationRequestWaitedForAdministrative::class => [SendWaitedForAdministrativeVacationRequestNotification::class],
|
VacationRequestWaitsForAdminApproval::class => [SendWaitedForAdministrativeVacationRequestNotification::class],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ namespace Toby\Domain\Listeners;
|
|||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForAdministrative;
|
use Toby\Domain\Events\VacationRequestWaitsForAdminApproval;
|
||||||
use Toby\Domain\Notifications\VacationRequestWaitedForAdministrativeNotification;
|
use Toby\Domain\Notifications\VacationRequestWaitsForAdminApprovalNotification;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
|
|
||||||
class SendWaitedForAdministrativeVacationRequestNotification
|
class SendWaitedForAdministrativeVacationRequestNotification
|
||||||
@ -16,10 +16,10 @@ class SendWaitedForAdministrativeVacationRequestNotification
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(VacationRequestWaitedForAdministrative $event): void
|
public function handle(VacationRequestWaitsForAdminApproval $event): void
|
||||||
{
|
{
|
||||||
foreach ($this->getUsersForNotifications() as $user) {
|
foreach ($this->getUsersForNotifications() as $user) {
|
||||||
$user->notify(new VacationRequestWaitedForAdministrativeNotification($event->vacationRequest, $user));
|
$user->notify(new VacationRequestWaitsForAdminApprovalNotification($event->vacationRequest, $user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ namespace Toby\Domain\Listeners;
|
|||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForTechnical;
|
use Toby\Domain\Events\VacationRequestWaitsForTechApproval;
|
||||||
use Toby\Domain\Notifications\VacationRequestWaitedForTechnicalNotification;
|
use Toby\Domain\Notifications\VacationRequestWaitsForTechApprovalNotification;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
|
|
||||||
class SendWaitedForTechnicalVacationRequestNotification
|
class SendWaitedForTechnicalVacationRequestNotification
|
||||||
@ -16,10 +16,10 @@ class SendWaitedForTechnicalVacationRequestNotification
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(VacationRequestWaitedForTechnical $event): void
|
public function handle(VacationRequestWaitsForTechApproval $event): void
|
||||||
{
|
{
|
||||||
foreach ($this->getUsersForNotifications() as $user) {
|
foreach ($this->getUsersForNotifications() as $user) {
|
||||||
$user->notify(new VacationRequestWaitedForTechnicalNotification($event->vacationRequest, $user));
|
$user->notify(new VacationRequestWaitsForTechApprovalNotification($event->vacationRequest, $user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class VacationRequestApprovedNotification extends Notification
|
|||||||
$user = $this->user->first_name;
|
$user = $this->user->first_name;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
$requester = $this->vacationRequest->user->fullName;
|
$requester = $this->vacationRequest->user->fullName;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class VacationRequestCancelledNotification extends Notification
|
|||||||
$user = $this->user->first_name;
|
$user = $this->user->first_name;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
$requester = $this->vacationRequest->user->fullName;
|
$requester = $this->vacationRequest->user->fullName;
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class VacationRequestCreatedNotification extends Notification
|
|||||||
$user = $this->vacationRequest->user->first_name;
|
$user = $this->vacationRequest->user->first_name;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
$appName = config("app.name");
|
$appName = config("app.name");
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class VacationRequestRejectedNotification extends Notification
|
|||||||
$user = $this->user->first_name;
|
$user = $this->user->first_name;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
$requester = $this->vacationRequest->user->fullName;
|
$requester = $this->vacationRequest->user->fullName;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use InvalidArgumentException;
|
|||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
|
||||||
class VacationRequestWaitedForAdministrativeNotification extends Notification
|
class VacationRequestWaitsForAdminApprovalNotification extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ class VacationRequestWaitedForAdministrativeNotification extends Notification
|
|||||||
$requester = $this->vacationRequest->user->fullName;
|
$requester = $this->vacationRequest->user->fullName;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
@ -11,7 +11,7 @@ use InvalidArgumentException;
|
|||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
|
||||||
class VacationRequestWaitedForTechnicalNotification extends Notification
|
class VacationRequestWaitsForTechApprovalNotification extends Notification
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ class VacationRequestWaitedForTechnicalNotification extends Notification
|
|||||||
$requester = $this->vacationRequest->user->fullName;
|
$requester = $this->vacationRequest->user->fullName;
|
||||||
$title = $this->vacationRequest->name;
|
$title = $this->vacationRequest->name;
|
||||||
$type = $this->vacationRequest->type->label();
|
$type = $this->vacationRequest->type->label();
|
||||||
$from = $this->vacationRequest->from->format("d.m.Y");
|
$from = $this->vacationRequest->from->toDisplayDate();
|
||||||
$to = $this->vacationRequest->to->format("d.m.Y");
|
$to = $this->vacationRequest->to->toDisplayDate();
|
||||||
$days = $this->vacationRequest->vacations()->count();
|
$days = $this->vacationRequest->vacations()->count();
|
||||||
|
|
||||||
return (new MailMessage())
|
return (new MailMessage())
|
@ -13,8 +13,8 @@ use Toby\Domain\Events\VacationRequestApproved;
|
|||||||
use Toby\Domain\Events\VacationRequestCancelled;
|
use Toby\Domain\Events\VacationRequestCancelled;
|
||||||
use Toby\Domain\Events\VacationRequestCreated;
|
use Toby\Domain\Events\VacationRequestCreated;
|
||||||
use Toby\Domain\Events\VacationRequestRejected;
|
use Toby\Domain\Events\VacationRequestRejected;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForAdministrative;
|
use Toby\Domain\Events\VacationRequestWaitsForAdminApproval;
|
||||||
use Toby\Domain\Events\VacationRequestWaitedForTechnical;
|
use Toby\Domain\Events\VacationRequestWaitsForTechApproval;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
|
|
||||||
class VacationRequestStateManager
|
class VacationRequestStateManager
|
||||||
@ -71,14 +71,14 @@ class VacationRequestStateManager
|
|||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::WaitingForTechnical);
|
$this->changeState($vacationRequest, VacationRequestState::WaitingForTechnical);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestWaitedForTechnical($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestWaitsForTechApproval($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function waitForAdministrative(VacationRequest $vacationRequest): void
|
public function waitForAdministrative(VacationRequest $vacationRequest): void
|
||||||
{
|
{
|
||||||
$this->changeState($vacationRequest, VacationRequestState::WaitingForAdministrative);
|
$this->changeState($vacationRequest, VacationRequestState::WaitingForAdministrative);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(new VacationRequestWaitedForAdministrative($vacationRequest));
|
$this->dispatcher->dispatch(new VacationRequestWaitsForAdminApproval($vacationRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void
|
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void
|
||||||
|
@ -12,7 +12,7 @@ use Tests\Traits\InteractsWithYearPeriods;
|
|||||||
use Toby\Domain\Enums\Role;
|
use Toby\Domain\Enums\Role;
|
||||||
use Toby\Domain\Enums\VacationRequestState;
|
use Toby\Domain\Enums\VacationRequestState;
|
||||||
use Toby\Domain\Enums\VacationType;
|
use Toby\Domain\Enums\VacationType;
|
||||||
use Toby\Domain\Notifications\VacationRequestWaitedForTechnicalNotification;
|
use Toby\Domain\Notifications\VacationRequestWaitsForTechApprovalNotification;
|
||||||
use Toby\Domain\VacationRequestStateManager;
|
use Toby\Domain\VacationRequestStateManager;
|
||||||
use Toby\Eloquent\Models\User;
|
use Toby\Eloquent\Models\User;
|
||||||
use Toby\Eloquent\Models\VacationRequest;
|
use Toby\Eloquent\Models\VacationRequest;
|
||||||
@ -64,7 +64,7 @@ class VacationRequestNotificationTest extends TestCase
|
|||||||
|
|
||||||
$this->stateManager->waitForTechnical($vacationRequest);
|
$this->stateManager->waitForTechnical($vacationRequest);
|
||||||
|
|
||||||
Notification::assertSentTo($technicalApprover, VacationRequestWaitedForTechnicalNotification::class);
|
Notification::assertSentTo($technicalApprover, VacationRequestWaitsForTechApprovalNotification::class);
|
||||||
Notification::assertNotSentTo([$user, $administrativeApprover], VacationRequestWaitedForTechnicalNotification::class);
|
Notification::assertNotSentTo([$user, $administrativeApprover], VacationRequestWaitsForTechApprovalNotification::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user