Rename component.component to component_id with relationship name change Rename more instances of parent to component Working on Incident Repository Fix Incident seeder component_id is fillable within the model Fix bad relationship Finished Incident repository Added Metric repository Updated tests for new dingo release
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace CachetHQ\Cachet\Controllers\Api;
|
|
|
|
use Input;
|
|
use Dingo\Api\Routing\ControllerTrait;
|
|
use Illuminate\Routing\Controller;
|
|
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
|
|
|
class MetricController extends Controller {
|
|
|
|
use ControllerTrait;
|
|
|
|
protected $metric;
|
|
|
|
public function __construct(MetricRepository $metric) {
|
|
$this->metric = $metric;
|
|
}
|
|
/**
|
|
* Get all metrics
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
*/
|
|
public function getMetrics() {
|
|
return $this->metric->all();
|
|
}
|
|
|
|
/**
|
|
* Get a single metric
|
|
*
|
|
* @param int $id
|
|
*
|
|
* @return Metric
|
|
*/
|
|
public function getMetric($id) {
|
|
return $this->metric->findOrFail($id);
|
|
}
|
|
|
|
/**
|
|
* Create a new metric
|
|
*
|
|
* @return Metric
|
|
*/
|
|
public function postMetrics() {
|
|
return $this->metric->create(Input::all());
|
|
}
|
|
|
|
/**
|
|
* Update an existing metric
|
|
*
|
|
* @param int $id
|
|
*
|
|
* @return Metric
|
|
*/
|
|
public function putMetric($id) {
|
|
return $this->metric->update($id, Input::all());
|
|
}
|
|
}
|