auth = $auth; } /** * Handle the update metric command. * * @param \CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand $command * * @return \CachetHQ\Cachet\Models\Metric */ public function handle(UpdateMetricCommand $command) { $metric = $command->metric; $metric->update($this->filter($command)); event(new MetricWasUpdatedEvent($this->auth->user(), $metric)); return $metric; } /** * Filter the command data. * * @param \CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand $command * * @return array */ protected function filter(UpdateMetricCommand $command) { $params = [ 'name' => $command->name, 'suffix' => $command->suffix, 'description' => $command->description, 'default_value' => $command->default_value, 'calc_type' => $command->calc_type, 'display_chart' => $command->display_chart, 'places' => $command->places, 'default_view' => $command->default_view, 'threshold' => $command->threshold, 'order' => $command->order, 'visible' => $command->visible, ]; return array_filter($params, function ($val) { return $val !== null; }); } }