_saveMetric($metric); } /** * Update an existing metric * * @param int $id * * @return Metric */ public function putMetric($id) { $metric = $this->getMetric($id); $metric->fill(Input::all()); return $this->_saveMetric($metric); } /** * Function for saving a metric, and returning appropriate error codes * * @param Metric $metric * * @return Metric */ private function _saveMetric($metric) { if ($metric->isValid()) { try { $metric->saveOrFail(); return $metric; } catch (Exception $e) { App::abort(500, $e->getMessage()); } } else { App::abort(404, $metric->getErrors()->first()); } } }