Added UpdateMetric and UpdateMetricPoint commands

This commit is contained in:
James Brooks
2015-09-23 18:38:42 +01:00
parent b8b81f7e1c
commit 18f98d19f0
9 changed files with 384 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Models\Metric;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
@@ -96,7 +97,16 @@ class MetricController extends AbstractApiController
public function putMetric(Metric $metric)
{
try {
$metric->update(Binput::all());
$metric = $this->dispatch(new UpdateMetricCommand(
$metric,
Binput::get('name'),
Binput::get('suffix'),
Binput::get('description'),
Binput::get('default_value'),
Binput::get('calc_type', 0),
Binput::get('display_chart'),
Binput::get('places')
));
} catch (Exception $e) {
throw new BadRequestHttpException();
}