This commit is contained in:
Adrian Hopek
2022-04-22 12:41:00 +02:00
parent 7d12a1a153
commit fad4290cc3
33 changed files with 599 additions and 78 deletions

View File

@@ -20,7 +20,17 @@ class VacationRequestCreatedNotification extends Notification
public function via(): array
{
return ["mail"];
return ["mail", "slack"];
}
public function toSlack(): string
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
return implode("\n", [
$this->buildDescription(),
"<${url}|Zobacz szczegóły>",
]);
}
/**
@@ -80,18 +90,16 @@ class VacationRequestCreatedNotification extends Notification
protected function buildDescription(): string
{
$name = $this->vacationRequest->name;
$appName = config("app.name");
if ($this->vacationRequest->creator()->is($this->vacationRequest->user)) {
return __("The vacation request :title has been created correctly in the :appName.", [
return __("The vacation request :title for user :user has been created successfully.", [
"user" => $this->vacationRequest->user->profile->full_name,
"title" => $name,
"appName" => $appName,
]);
}
return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [
return __("The vacation request :title has been created successfully by user :creator on your behalf.", [
"title" => $this->vacationRequest->name,
"appName" => $appName,
"creator" => $this->vacationRequest->creator->profile->full_name,
]);
}

View File

@@ -22,7 +22,17 @@ class VacationRequestStatusChangedNotification extends Notification
public function via(): array
{
return ["mail"];
return ["mail", "slack"];
}
public function toSlack(): string
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
return implode("\n", [
$this->buildDescription(),
"<${url}|Zobacz szczegóły>",
]);
}
/**
@@ -43,27 +53,17 @@ class VacationRequestStatusChangedNotification extends Notification
protected function buildMailMessage(string $url): MailMessage
{
$user = $this->user->profile->first_name;
$title = $this->vacationRequest->name;
$type = $this->vacationRequest->type->label();
$status = $this->vacationRequest->state->label();
$from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->profile->full_name;
return (new MailMessage())
->greeting(__("Hi :user!", [
"user" => $user,
]))
->subject(__("Vacation request :title has been :status", [
"title" => $title,
"status" => $status,
]))
->line(__("The vacation request :title from user :requester has been :status.", [
"title" => $title,
"requester" => $requester,
"status" => $status,
]))
->subject($this->buildSubject())
->line($this->buildDescription())
->line(__("Vacation type: :type", [
"type" => $type,
]))
@@ -74,4 +74,21 @@ class VacationRequestStatusChangedNotification extends Notification
]))
->action(__("Click here for details"), $url);
}
protected function buildSubject(): string
{
return __("Vacation request :title has been :status", [
"title" => $this->vacationRequest->name,
"status" => $this->vacationRequest->state->label(),
]);
}
protected function buildDescription(): string
{
return __("The vacation request :title from user :requester has been :status.", [
"title" => $this->vacationRequest->name,
"requester" => $this->vacationRequest->user->profile->full_name,
"status" => $this->vacationRequest->state->label(),
]);
}
}

View File

@@ -23,7 +23,17 @@ class VacationRequestWaitsForApprovalNotification extends Notification
public function via(): array
{
return ["mail"];
return ["mail", "slack"];
}
public function toSlack(): string
{
$url = route("vacation.requests.show", ["vacationRequest" => $this->vacationRequest->id]);
return implode("\n", [
$this->buildDescription(),
"<${url}|Zobacz szczegóły>",
]);
}
/**