diff --git a/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php index 94ccef00..bc62631d 100644 --- a/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php +++ b/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php @@ -71,7 +71,7 @@ class SendIncidentEmailNotificationHandler 'subject' => 'New incident reported.', 'has_component' => ($event->incident->component) ? true : false, 'component_name' => $component ? $component->name : null, - 'status' => $incident->humanStatus, + 'status' => $incident->human_status, 'html_content' => $incident->formattedMessage, 'text_content' => $incident->message, 'token' => $subscriber->token, diff --git a/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php b/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php index 877f2f08..6c7469fc 100644 --- a/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php +++ b/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php @@ -66,7 +66,7 @@ class SendMaintenanceEmailNotificationHandler $mail = [ 'email' => $subscriber->email, 'subject' => 'Scheduled maintenance.', - 'status' => $data->humanStatus, + 'status' => $data->human_status, 'html_content' => $data->formattedMessage, 'text_content' => $data->message, 'scheduled_at' => $data->scheduled_at_formatted, diff --git a/app/Models/Incident.php b/app/Models/Incident.php index cc75570a..aebd8f91 100644 --- a/app/Models/Incident.php +++ b/app/Models/Incident.php @@ -22,13 +22,6 @@ class Incident extends Model implements HasPresenter { use SoftDeletes, ValidatingTrait; - /** - * The accessors to append to the model's serialized form. - * - * @var string[] - */ - protected $appends = ['human_status']; - /** * The attributes that should be casted to native types. * @@ -118,18 +111,6 @@ class Incident extends Model implements HasPresenter return $this->belongsTo(Component::class, 'component_id', 'id'); } - /** - * Returns a human readable version of the status. - * - * @return string - */ - public function getHumanStatusAttribute() - { - $statuses = trans('cachet.incidents.status'); - - return $statuses[$this->status]; - } - /** * Returns whether the "incident" is scheduled or not. * diff --git a/app/Presenters/IncidentPresenter.php b/app/Presenters/IncidentPresenter.php index 6d7d2053..db84d1e7 100644 --- a/app/Presenters/IncidentPresenter.php +++ b/app/Presenters/IncidentPresenter.php @@ -180,6 +180,18 @@ class IncidentPresenter extends AbstractPresenter } } + /** + * Returns a human readable version of the status. + * + * @return string + */ + public function human_status() + { + $statuses = trans('cachet.incidents.status'); + + return $statuses[$this->wrappedObject->status]; + } + /** * Convert the presenter instance to an array. * @@ -188,6 +200,7 @@ class IncidentPresenter extends AbstractPresenter public function toArray() { return array_merge($this->wrappedObject->toArray(), [ + 'human_status' => $this->human_status(), 'scheduled_at' => $this->scheduled_at(), 'created_at' => $this->created_at(), 'updated_at' => $this->updated_at(),