#71 - annual summary #113

Merged
Baakoma merged 16 commits from #71-annual-summary into main 2022-04-07 14:33:15 +02:00
Showing only changes of commit c58d982f98 - Show all commits

View File

@@ -8,7 +8,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use InvalidArgumentException; use InvalidArgumentException;
use Toby\Domain\States\VacationRequest\WaitingForTechnical;
use Toby\Eloquent\Models\User; use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\VacationRequest; use Toby\Eloquent\Models\VacationRequest;
@@ -44,6 +43,8 @@ class VacationRequestWaitsForApprovalNotification extends Notification
protected function buildMailMessage(string $url): MailMessage protected function buildMailMessage(string $url): MailMessage
{ {
$user = $this->user->first_name; $user = $this->user->first_name;
$requester = $this->vacationRequest->user->fullName;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label(); $type = $this->vacationRequest->type->label();
$from = $this->vacationRequest->from->toDisplayString(); $from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString(); $to = $this->vacationRequest->to->toDisplayString();
@@ -53,8 +54,13 @@ class VacationRequestWaitsForApprovalNotification extends Notification
->greeting(__("Hi :user!", [ ->greeting(__("Hi :user!", [
"user" => $user, "user" => $user,
])) ]))
->subject($this->buildSubject()) ->subject(__("Vacation request :title is waiting for your approval", [
->line($this->buildDescription()) "title" => $title,
]))
->line(__("The vacation request :title from user: :requester is waiting for your approval.", [
"title" => $title,
"requester" => $requester,
]))
->line(__("Vacation type: :type", [ ->line(__("Vacation type: :type", [
"type" => $type, "type" => $type,
])) ]))
@@ -65,37 +71,4 @@ class VacationRequestWaitsForApprovalNotification extends Notification
])) ]))
->action(__("Click here for details"), $url); ->action(__("Click here for details"), $url);
} }
protected function buildSubject(): string
{
$title = $this->vacationRequest->name;
if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) {
return __("Vacation request :title is waiting for your technical approval", [
"title" => $title,
]);
}
return __("Vacation request :title is waiting for your administrative approval", [
"title" => $title,
]);
}
protected function buildDescription(): string
{
$title = $this->vacationRequest->name;
$requester = $this->vacationRequest->user->name;
if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) {
return __("The vacation request :title from user: :requester is waiting for your technical approval.", [
"title" => $title,
"requester" => $requester,
]);
}
return __("The vacation request :title from user: :requester is waiting for your administrative approval.", [
"title" => $title,
"requester" => $requester,
]);
}
} }