Skip to content

Commit

Permalink
Merge pull request #52 from EscolaLMS/feature/STAR-40
Browse files Browse the repository at this point in the history
Feature/star 40
  • Loading branch information
HerbertIV authored Dec 16, 2022
2 parents 4d9b6b6 + 5b34854 commit 26518a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
16 changes: 3 additions & 13 deletions src/Consultations/CommonConsultationVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace EscolaLms\TemplatesEmail\Consultations;

use DateTimeInterface;
use EscolaLms\Consultations\Models\ConsultationUserPivot;
use EscolaLms\Core\Models\User;
use EscolaLms\Templates\Events\EventWrapper;
use EscolaLms\TemplatesEmail\Core\EmailVariables;
use Illuminate\Support\Carbon;

abstract class CommonConsultationVariables extends EmailVariables
{
Expand All @@ -21,26 +19,18 @@ public static function mockedVariables(?User $user = null): array
return array_merge(parent::mockedVariables(), [
self::VAR_USER_NAME => $faker->name(),
self::VAR_CONSULTATION_TITLE => $faker->word(),
self::VAR_CONSULTATION_PROPOSED_TERM => $faker->dateTime(),
self::VAR_CONSULTATION_PROPOSED_TERM => $faker->dateTime()->format('Y-m-d H:i:s'),
]);
}

public static function variablesFromEvent(EventWrapper $event): array
{
if ($event->getWebinar()->active_to instanceof DateTimeInterface) {
$proposedTerm = $event->getConsultationTerm()->executed_at;
} else {
$proposedTerm = Carbon::make($event->getConsultationTerm()->executed_at);
}

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 => $proposedTerm ?
$proposedTerm
self::VAR_CONSULTATION_PROPOSED_TERM => $event->getConsultationTerm()->executed_at
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s') :
'',
->format('Y-m-d H:i:s'),
]);
}

Expand Down
16 changes: 3 additions & 13 deletions src/Webinar/CommonWebinarVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace EscolaLms\TemplatesEmail\Webinar;

use Carbon\Carbon;
use DateTimeInterface;
use EscolaLms\Core\Models\User;
use EscolaLms\Templates\Events\EventWrapper;
use EscolaLms\TemplatesEmail\Core\EmailVariables;
Expand All @@ -21,26 +19,18 @@ public static function mockedVariables(?User $user = null): array
return array_merge(parent::mockedVariables(), [
self::VAR_USER_NAME => $faker->name(),
self::VAR_WEBINAR_TITLE => $faker->word(),
self::VAR_WEBINAR_PROPOSED_TERM => $faker->dateTime(),
self::VAR_WEBINAR_PROPOSED_TERM => $faker->dateTime()->format('Y-m-d H:i:s'),
]);
}

public static function variablesFromEvent(EventWrapper $event): array
{
if ($event->getWebinar()->active_to instanceof DateTimeInterface) {
$proposedTerm = $event->getWebinar()->active_to;
} else {
$proposedTerm = Carbon::make($event->getWebinar()->active_to);
}

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 => $proposedTerm ?
$proposedTerm
self::VAR_WEBINAR_PROPOSED_TERM => $event->getWebinar()->active_to
->setTimezone($event->getUser()->current_timezone)
->format('Y-m-d H:i:s') :
'',
->format('Y-m-d H:i:s'),
]);
}

Expand Down

0 comments on commit 26518a1

Please sign in to comment.