Fix listing of metric points.
This commit is contained in:
@@ -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 () {
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user