mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 13:38:20 +01:00
Improved and fixed the report incident command handler
This commit is contained in:
parent
4a07bb4a7f
commit
bb106d35fe
@ -29,24 +29,29 @@ class ReportIncidentCommandHandler
|
||||
*/
|
||||
public function handle(ReportIncidentCommand $command)
|
||||
{
|
||||
$incident = Incident::create([
|
||||
'name' => $command->name,
|
||||
'status' => $command->status,
|
||||
'message' => $command->message,
|
||||
'visible' => $command->visible,
|
||||
'component_id' => $command->component_id,
|
||||
]);
|
||||
$data = [
|
||||
'name' => $command->name,
|
||||
'status' => $command->status,
|
||||
'message' => $command->message,
|
||||
'visible' => $command->visible,
|
||||
];
|
||||
|
||||
// Link with the component.
|
||||
if ($command->component_id) {
|
||||
$data['component_id'] = $command->component_id;
|
||||
}
|
||||
|
||||
// The incident occurred at a different time.
|
||||
if ($command->incident_date) {
|
||||
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
|
||||
|
||||
$incident->update([
|
||||
'created_at' => $incidentDate,
|
||||
'updated_at' => $incidentDate,
|
||||
]);
|
||||
$data['created_at'] = $incidentDate;
|
||||
$data['updated_at'] = $incidentDate;
|
||||
}
|
||||
|
||||
// Create the incident
|
||||
$incident = Incident::create($data);
|
||||
|
||||
// Update the component.
|
||||
if ($command->component_id) {
|
||||
Component::find($command->component_id)->update([
|
||||
|
Loading…
x
Reference in New Issue
Block a user