Abstract presenter, timestampstrait, update api responses
This commit is contained in:
@@ -16,6 +16,7 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use CachetHQ\Cachet\Repositories\Component\ComponentRepository;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ComponentController extends AbstractApiController
|
||||
@@ -58,18 +59,20 @@ class ComponentController extends AbstractApiController
|
||||
*/
|
||||
public function getComponent($id)
|
||||
{
|
||||
return $this->component->findOrFail($id);
|
||||
return $this->item($this->component->findOrFail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new component.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
public function postComponents()
|
||||
public function postComponents(Guard $auth)
|
||||
{
|
||||
$component = $this->component->create(
|
||||
$this->auth->user()->id,
|
||||
$auth->user()->id,
|
||||
Binput::except('tags')
|
||||
);
|
||||
|
||||
@@ -87,7 +90,7 @@ class ComponentController extends AbstractApiController
|
||||
$component->tags()->sync($componentTags);
|
||||
}
|
||||
|
||||
return $component;
|
||||
return $this->item($component);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +117,7 @@ class ComponentController extends AbstractApiController
|
||||
$component->tags()->sync($componentTags);
|
||||
}
|
||||
|
||||
return $component;
|
||||
return $this->item($component);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IncidentController extends AbstractApiController
|
||||
@@ -57,17 +58,19 @@ class IncidentController extends AbstractApiController
|
||||
*/
|
||||
public function getIncident($id)
|
||||
{
|
||||
return $this->incident->findOrFail($id);
|
||||
return $this->item($this->incident->findOrFail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new incident.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
public function postIncidents()
|
||||
public function postIncidents(Guard $auth)
|
||||
{
|
||||
return $this->incident->create($this->auth->user()->id, Binput::all());
|
||||
return $this->item($this->incident->create($auth->user()->id, Binput::all()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +82,7 @@ class IncidentController extends AbstractApiController
|
||||
*/
|
||||
public function putIncident($id)
|
||||
{
|
||||
return $this->incident->update($id, Binput::all());
|
||||
return $this->item($this->incident->update($id, Binput::all()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ class MetricController extends AbstractApiController
|
||||
*/
|
||||
public function postMetrics()
|
||||
{
|
||||
return $this->metric->create(Binput::all());
|
||||
return $this->item($this->metric->create(Binput::all()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ class MetricController extends AbstractApiController
|
||||
*/
|
||||
public function putMetric($id)
|
||||
{
|
||||
return $this->metric->update($id, Binput::all());
|
||||
return $this->item($this->metric->update($id, Binput::all()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ class MetricPointController extends AbstractApiController
|
||||
*/
|
||||
public function getMetricPoints($id)
|
||||
{
|
||||
return $this->metricPoint->findOrFail($id);
|
||||
return $this->item($this->metricPoint->findOrFail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class MetricPointController extends AbstractApiController
|
||||
*/
|
||||
public function postMetricPoints($id)
|
||||
{
|
||||
return $this->metricPoint->create($id, Binput::all());
|
||||
return $this->item($this->metricPoint->create($id, Binput::all()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ class MetricPointController extends AbstractApiController
|
||||
$metricPoint = $this->metricPoint->findOrFail($pointId);
|
||||
$metricPoint->update(Binput::all());
|
||||
|
||||
return $metricPoint;
|
||||
return $this->item($metricPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user