Skip to content

Commit

Permalink
Merge pull request #54 from EscolaLMS/feature/STAR-977
Browse files Browse the repository at this point in the history
Feature/star 977
  • Loading branch information
HerbertIV authored Jan 11, 2023
2 parents 5bbc200 + fe2ee44 commit 68d368b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/Consultations/CommonConsultationVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EscolaLms\TemplatesEmail\Consultations;

use Carbon\Carbon;
use EscolaLms\Consultations\Models\ConsultationUserPivot;
use EscolaLms\Core\Models\User;
use EscolaLms\Templates\Events\EventWrapper;
Expand All @@ -25,12 +26,20 @@ public static function mockedVariables(?User $user = null): array

public static function variablesFromEvent(EventWrapper $event): array
{
$executedAt = $event->getConsultationTerm()->executed_at ?? '';
if ($executedAt) {
if (!$executedAt instanceof Carbon) {
$executedAt = Carbon::make($executedAt);
}
$executedAt = $executedAt
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s');
}

return array_merge(parent::variablesFromEvent($event), [
self::VAR_USER_NAME => $event->getUser()->name,
self::VAR_CONSULTATION_TITLE => $event->getConsultationTerm()->consultation->name,
self::VAR_CONSULTATION_PROPOSED_TERM => $event->getConsultationTerm()->executed_at
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s'),
self::VAR_CONSULTATION_PROPOSED_TERM => $executedAt,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/EmailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function send(EventWrapper $event, array $sections): bool
}
$email = $event->getUser()->email;
if (method_exists($event, 'getEmail')) {
$email = $event->getEmail();
$email = $event->getEmail() ?? $email;
}
$mailable = new EmailMailable();
$mailable->to($email);
Expand Down
15 changes: 12 additions & 3 deletions src/Webinar/CommonWebinarVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use EscolaLms\Templates\Events\EventWrapper;
use EscolaLms\TemplatesEmail\Core\EmailVariables;
use EscolaLms\Webinar\Models\Webinar;
use Illuminate\Support\Carbon;

abstract class CommonWebinarVariables extends EmailVariables
{
Expand All @@ -25,12 +26,20 @@ public static function mockedVariables(?User $user = null): array

public static function variablesFromEvent(EventWrapper $event): array
{
$proposedTerm = $event->getWebinar()->active_to ?? '';
if ($proposedTerm) {
if (!$proposedTerm instanceof Carbon) {
$proposedTerm = Carbon::make($proposedTerm);
}
$proposedTerm = $proposedTerm
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s');
}

return array_merge(parent::variablesFromEvent($event), [
self::VAR_USER_NAME => $event->getUser()->name,
self::VAR_WEBINAR_TITLE => $event->getWebinar()->name,
self::VAR_WEBINAR_PROPOSED_TERM => $event->getWebinar()->active_to
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s'),
self::VAR_WEBINAR_PROPOSED_TERM => $proposedTerm,
]);
}

Expand Down

0 comments on commit 68d368b

Please sign in to comment.