public function handle(UpdateIncidentCommand $command)
    {
        if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) {
            $command->message = $this->parseTemplate($template, $command);
        }

        $incident = $command->incident;
        $incident->fill($this->filter($command));

        // The incident occurred at a different time.
        if ($occurredAt = $command->occurred_at) {
            if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) {
                $incident->fill(['occurred_at' => $date]);
            } else {
                throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}");
            }
        }

        // Rather than making lots of updates, just fill and save.
        $incident->save();

        // Store any meta?
        if ($meta = $command->meta) {
            $this->storeMeta($command->meta, 'incidents', $incident->id);
        }

        // Update the component.
        if ($component = Component::find($command->component_id)) {
            execute(new UpdateComponentCommand(
                Component::find($command->component_id),
                null,
                null,
                $command->component_status,
                null,
                null,
                null,
                null,
                null,
                false
            ));
        }

        event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));

        return $incident;
    }
public function handle(UpdateIncidentCommand $command)
    {
        if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) {
            $command->message = $this->parseTemplate($template, $command);
        }

        $incident = $command->incident;
        $incident->fill($this->filter($command));

        // The incident occurred at a different time.
        if ($occurredAt = $command->occurred_at) {
            if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) {
                $incident->fill(['occurred_at' => $date]);
            } else {
                throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}");
            }
        }

        // Rather than making lots of updates, just fill and save.
        $incident->save();

        // Store any meta?
        if ($meta = $command->meta) {
            $this->storeMeta($command->meta, 'incidents', $incident->id);
        }

        // Update the component.
        if ($component = Component::find($command->component_id)) {
            execute(new UpdateComponentCommand(
                Component::find($command->component_id),
                null,
                null,
                $command->component_status,
                null,
                null,
                null,
                null,
                null,
                false
            ));
        }

        event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));

        return $incident;
    }
public function handle ( UpdateIncidentCommand $ command ) { if ( $ template = IncidentTemplate :: where ( 'slug' , '=' , $ command -> template ) -> first ( ) ) { $ command -> message = $ this -> parseTemplate ( $ template , $ command ) ; } $ incident = $ command -> incident ; $ incident -> fill ( $ this -> filter ( $ command ) ) ; // The incident occurred at a different time. if ( $ occurredAt = $ command -> occurred_at ) { if ( $ date = $ this -> dates -> create ( 'Y-m-d H:i' , $ occurredAt ) ) { $ incident -> fill ( [ 'occurred_at' => $ date ] ) ; } else { throw new InvalidIncidentTimestampException ( "Unable to pass timestamp {$occurredAt}" ) ; } } // Rather than making lots of updates, just fill and save. $ incident -> save ( ) ; // Store any meta? if ( $ meta = $ command -> meta ) { $ this -> storeMeta ( $ command -> meta , 'incidents' , $ incident -> id ) ; } // Update the component. if ( $ component = Component :: find ( $ command -> component_id ) ) { execute ( new UpdateComponentCommand ( Component :: find ( $ command -> component_id ) , null , null , $ command -> component_status , null , null , null , null , null , false ) ) ; } event ( new IncidentWasUpdatedEvent ( $ this -> auth -> user ( ) , $ incident ) ) ; return $ incident ; }
Handle the update incident command.

@param \CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand $command

@return \CachetHQ\Cachet\Models\Incident
Handle the update incident command .