This commit is contained in:
Adrian Hopek 2022-04-07 14:04:51 +02:00
parent f09565ac9d
commit c58d982f98

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,
]);
}
} }