diff --git a/composer.json b/composer.json index ce5e4a6..86b54db 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,10 @@ "config": { "optimize-autoloader": false, "preferred-install": "dist", - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "php-http/discovery": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/src/Consultations/CommonConsultationVariables.php b/src/Consultations/CommonConsultationVariables.php index 7d88b44..2c77bf8 100644 --- a/src/Consultations/CommonConsultationVariables.php +++ b/src/Consultations/CommonConsultationVariables.php @@ -4,6 +4,7 @@ use Carbon\Carbon; use EscolaLms\Consultations\Models\ConsultationUserPivot; +use EscolaLms\Consultations\Services\Contracts\ConsultationServiceContract; use EscolaLms\Core\Models\User; use EscolaLms\Templates\Events\EventWrapper; use EscolaLms\TemplatesEmail\Core\EmailVariables; @@ -13,14 +14,19 @@ abstract class CommonConsultationVariables extends EmailVariables const VAR_USER_NAME = '@VarUserName'; const VAR_CONSULTATION_TITLE = '@VarConsultationTitle'; const VAR_CONSULTATION_PROPOSED_TERM = '@VarConsultationProposedTerm'; + const VAR_CONSULTATION_DATE_TIME_START = '@VarConsultationDateTimeStart'; + const VAR_CONSULTATION_DATE_TIME_END = '@VarConsultationDateTimeEnd'; public static function mockedVariables(?User $user = null): array { $faker = \Faker\Factory::create(); + $date = $faker->dateTime(); return array_merge(parent::mockedVariables(), [ self::VAR_USER_NAME => $faker->name(), self::VAR_CONSULTATION_TITLE => $faker->word(), - self::VAR_CONSULTATION_PROPOSED_TERM => $faker->dateTime()->format('Y-m-d H:i:s'), + self::VAR_CONSULTATION_PROPOSED_TERM => $date->format('Y-m-d H:i:s'), + self::VAR_CONSULTATION_DATE_TIME_START => Carbon::parse($date)->toISOString(), + self::VAR_CONSULTATION_DATE_TIME_END => Carbon::parse($date)->addHour()->toISOString(), ]); } @@ -32,14 +38,18 @@ public static function variablesFromEvent(EventWrapper $event): array $executedAt = Carbon::make($executedAt); } $executedAt = $executedAt - ->setTimezone($event->getUser()->current_timezone) - ->format('Y-m-d H:i:s'); + ->setTimezone($event->getUser()->current_timezone); + } + $executedTo = $executedAt ? app(ConsultationServiceContract::class) + ->generateDateTo($executedAt, $event->getConsultationTerm()->consultation->getDuration()) : $executedAt; 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 => $executedAt, + self::VAR_CONSULTATION_PROPOSED_TERM => $executedAt->format('Y-m-d H:i:s'), + self::VAR_CONSULTATION_DATE_TIME_START => $executedAt->toISOString(), + self::VAR_CONSULTATION_DATE_TIME_END => $executedTo->toISOString(), ]); }