Added UpdateIncidentCommand

This commit is contained in:
James Brooks
2015-09-22 19:48:08 +01:00
parent 30b05f360d
commit b8b81f7e1c
6 changed files with 238 additions and 19 deletions

View File

@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
use CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Models\Incident;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
@@ -89,17 +90,17 @@ class IncidentController extends AbstractApiController
*/
public function putIncident(Incident $incident)
{
$incidentData = array_filter(Binput::only([
'name',
'message',
'status',
'component_id',
'notify',
'visible',
]));
try {
$incident->update($incidentData);
$incident = $this->dispatch(new UpdateIncidentCommand(
$incident,
Binput::get('name'),
Binput::get('status'),
Binput::get('message'),
Binput::get('visible', true),
Binput::get('component_id'),
Binput::get('component_status'),
Binput::get('notify', true)
));
} catch (Exception $e) {
throw new BadRequestHttpException();
}