From b68647df8eba8b8450f55a6ebe52e2fdd1027676 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Thu, 13 Aug 2015 23:23:18 +0100 Subject: [PATCH 1/2] Show the scheduled time if applicable. Closes #799 --- .../SendMaintenanceEmailNotificationHandler.php | 1 + app/Presenters/IncidentPresenter.php | 2 +- app/Presenters/Traits/TimestampsTrait.php | 11 +++++++++++ .../views/emails/incidents/maintenance-html.blade.php | 2 ++ .../views/emails/incidents/maintenance-text.blade.php | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php b/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php index 86123718..67ab3231 100644 --- a/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php +++ b/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php @@ -70,6 +70,7 @@ class SendMaintenanceEmailNotificationHandler 'status' => $data->humanStatus, 'htmlContent' => $data->formattedMessage, 'textContent' => $data->message, + 'scheduled_at' => $data->scheduled_at_formatted, 'token' => $subscriber->token, 'unsubscribeLink' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]), 'appUrl' => env('APP_URL'), diff --git a/app/Presenters/IncidentPresenter.php b/app/Presenters/IncidentPresenter.php index ad044303..4241f5fb 100644 --- a/app/Presenters/IncidentPresenter.php +++ b/app/Presenters/IncidentPresenter.php @@ -160,7 +160,7 @@ class IncidentPresenter extends AbstractPresenter public function toArray() { return array_merge($this->wrappedObject->toArray(), [ - 'scheduled_at' => $this->created_at(), + 'scheduled_at' => $this->scheduled_at(), 'created_at' => $this->created_at(), 'updated_at' => $this->updated_at(), ]); diff --git a/app/Presenters/Traits/TimestampsTrait.php b/app/Presenters/Traits/TimestampsTrait.php index 673d062a..ec1d029c 100644 --- a/app/Presenters/Traits/TimestampsTrait.php +++ b/app/Presenters/Traits/TimestampsTrait.php @@ -26,6 +26,17 @@ trait TimestampsTrait ->setTimezone($this->setting->get('app_timezone'))->toDateTimeString(); } + /** + * Present formatted date time. + * + * @return string + */ + public function scheduled_at() + { + return (new Date($this->wrappedObject->scheduled_at)) + ->setTimezone($this->setting->get('app_timezone'))->toDateTimeString(); + } + /** * Present formatted date time. * diff --git a/resources/views/emails/incidents/maintenance-html.blade.php b/resources/views/emails/incidents/maintenance-html.blade.php index d98d57ae..193ab558 100644 --- a/resources/views/emails/incidents/maintenance-html.blade.php +++ b/resources/views/emails/incidents/maintenance-html.blade.php @@ -7,6 +7,8 @@ @section('content') {!! trans('cachet.subscriber.email.maintenance.html', ['app_name' => Setting::get('app_name')]) !!} +

{{ $scheduled_at }}

+

{!! $status !!}

diff --git a/resources/views/emails/incidents/maintenance-text.blade.php b/resources/views/emails/incidents/maintenance-text.blade.php index c1a0f20a..2ba6b31a 100644 --- a/resources/views/emails/incidents/maintenance-text.blade.php +++ b/resources/views/emails/incidents/maintenance-text.blade.php @@ -1,5 +1,7 @@ {!! trans('cachet.subscriber.email.maintenance.text', ['app_name' => Setting::get('app_name')]) !!} +{{ $scheduled_at }} + {!! $status !!} {!! $textContent !!} From 8b0f1033e54a9f832e7c65854c382e1561dfd996 Mon Sep 17 00:00:00 2001 From: Joseph Cohen Date: Thu, 13 Aug 2015 23:38:54 -0500 Subject: [PATCH 2/2] Fix typo assign --- app/Http/Controllers/Admin/ScheduleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Admin/ScheduleController.php b/app/Http/Controllers/Admin/ScheduleController.php index 8b6249df..195348b2 100644 --- a/app/Http/Controllers/Admin/ScheduleController.php +++ b/app/Http/Controllers/Admin/ScheduleController.php @@ -109,7 +109,7 @@ class ScheduleController extends Controller $scheduleData['status'] = 0; try { - Incident::create($scheduleData); + $incident = Incident::create($scheduleData); } catch (ValidationException $e) { return Redirect::route('dashboard.schedule.add') ->withInput(Binput::all())