Remove repositories from the API and switch cipher to rijndael-256
This commit is contained in:
committed by
James Brooks
parent
d788691006
commit
106c1a034a
@@ -11,63 +11,57 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
|
||||
class MetricPointController extends AbstractApiController
|
||||
{
|
||||
/**
|
||||
* The metric point repository instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository
|
||||
*/
|
||||
protected $metricPoint;
|
||||
|
||||
/**
|
||||
* Create a new metric point controller instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository $metricPoint
|
||||
*/
|
||||
public function __construct(MetricPointRepository $metricPoint)
|
||||
{
|
||||
$this->metricPoint = $metricPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single metric point.
|
||||
*
|
||||
* @param int $id
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
* @param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public function getMetricPoints($id)
|
||||
public function getMetricPoints(Metric $metric, MetricPoint $metricPoint)
|
||||
{
|
||||
return $this->item($this->metricPoint->findOrFail($id));
|
||||
return $this->item($metricPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new metric point.
|
||||
*
|
||||
* @param int $id
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public function postMetricPoints($id)
|
||||
public function postMetricPoints(Metric $metric)
|
||||
{
|
||||
return $this->item($this->metricPoint->create($id, Binput::all()));
|
||||
$metricPointData = Binput::all();
|
||||
$metricPointData['metric_id'] = $metric->id;
|
||||
|
||||
try {
|
||||
$metricPoint = MetricPoint::create($metricPointData);
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
return $this->item($metricPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a metric point.
|
||||
*
|
||||
* @param int $metricId
|
||||
* @param int $pointId
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
* @param \CachetHQ\Cachet\Models\MetircPoint $metricPoint
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\MetricPoint
|
||||
*/
|
||||
public function putMetricPoint($metricId, $pointId)
|
||||
public function putMetricPoint(Metric $metric, MetricPoint $metricPoint)
|
||||
{
|
||||
$metricPoint = $this->metricPoint->findOrFail($pointId);
|
||||
$metricPoint->update(Binput::all());
|
||||
|
||||
return $this->item($metricPoint);
|
||||
@@ -76,14 +70,14 @@ class MetricPointController extends AbstractApiController
|
||||
/**
|
||||
* Destroys a metric point.
|
||||
*
|
||||
* @param int $metricId
|
||||
* @param int $pointId
|
||||
* @param \CachetHQ\Cachet\Models\Metric $metric
|
||||
* @param \CachetHQ\Cachet\Models\MetricPoint $metricPoint
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
*/
|
||||
public function deleteMetricPoint($metricId, $pointId)
|
||||
public function deleteMetricPoint(Metric $metric, MetricPoint $metricPoint)
|
||||
{
|
||||
$this->metricPoint->destroy($pointId);
|
||||
$metricPoint->delete();
|
||||
|
||||
return $this->noContent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user