Fix listing of metric points.

This commit is contained in:
James Brooks
2015-03-11 14:33:19 +00:00
parent e398c7f0ab
commit 1b11f3b675
5 changed files with 38 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ Route::api([
// Metrics
Route::get('metrics', 'MetricController@getMetrics');
Route::get('metrics/{id}', 'MetricController@getMetric');
Route::get('metrics/{id}/points', 'MetricPointController@getMetricPoint');
Route::get('metrics/{id}/points', 'MetricController@getMetricPoints');
// Api protected
Route::group(['protected' => true], function () {

View File

@@ -29,6 +29,7 @@ class MetricController extends Controller
{
$this->metric = $metric;
}
/**
* Get all metrics.
*
@@ -51,6 +52,18 @@ class MetricController extends Controller
return $this->metric->findOrFail($id);
}
/**
* Get all metric points.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getMetricPoints($id)
{
return $this->metric->points($id);
}
/**
* Create a new metric.
*

View File

@@ -29,15 +29,6 @@ class MetricPointController extends Controller
{
$this->metricPoint = $metricPoint;
}
/**
* Get all metric points.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getMetricPoints()
{
return $this->metricPoint->all();
}
/**
* Get a single metric point.
@@ -46,7 +37,7 @@ class MetricPointController extends Controller
*
* @return \CachetHQ\Cachet\Models\MetricPoint
*/
public function getMetricPoint($id)
public function getMetricPoints($id)
{
return $this->metricPoint->findOrFail($id);
}

View File

@@ -63,4 +63,18 @@ class EloquentMetricRepository extends EloquentRepository implements MetricRepos
return $metric;
}
/**
* Returns all metric point models.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function points($id)
{
$metric = $this->model->findOrFail($id);
return $metric->points;
}
}

View File

@@ -11,6 +11,15 @@ interface MetricRepository
*/
public function all();
/**
* Returns all metric point models.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function points($id);
/**
* Create a new model.
*