From 49f42b57c97669f2ac1e3f1c93cd7720574e1ba8 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 25 Nov 2014 20:31:07 +0000 Subject: [PATCH] You can now get metrics --- app/controllers/ApiController.php | 24 ++++++++++++++++++++++++ app/routes/api.php | 2 ++ 2 files changed, 26 insertions(+) diff --git a/app/controllers/ApiController.php b/app/controllers/ApiController.php index 3b10d987..92c767a7 100644 --- a/app/controllers/ApiController.php +++ b/app/controllers/ApiController.php @@ -106,6 +106,30 @@ return $this->saveIncident($incident); } + /** + * Get all metrics + * + * @return \Illuminate\Database\Eloquent\Collection + */ + public function getMetrics() { + return Metric::all(); + } + + /** + * Get a single metric + * + * @param int $id + * + * @return Metric + */ + public function getMetric($id) { + if ($metric = Metric::find($id)) { + return $metric; + } else { + App::abort(404, 'Metric not found'); + } + } + /** * Function for saving the incident, and returning appropriate error codes * diff --git a/app/routes/api.php b/app/routes/api.php index 13685a4c..397ab254 100644 --- a/app/routes/api.php +++ b/app/routes/api.php @@ -7,6 +7,8 @@ Route::get('components/{id}/incidents', 'ApiController@getComponentIncidents'); Route::get('incidents', 'ApiController@getIncidents'); Route::get('incidents/{id}', 'ApiController@getIncident'); + Route::get('metrics', 'ApiController@getMetrics'); + Route::get('metrics/{id}', 'ApiController@getMetric'); Route::group(['protected' => true], function() { Route::post('components', 'ApiController@postComponents');