Move HumanStatus to Presenter, see also #1258
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user