2014-11-26 23:20:31 +00:00
|
|
|
<?php
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2014-11-27 16:36:24 +00:00
|
|
|
namespace CachetHQ\Cachet\Controllers\Api;
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
|
2014-12-01 12:03:32 +00:00
|
|
|
use Dingo\Api\Routing\ControllerTrait;
|
|
|
|
use Illuminate\Routing\Controller;
|
2015-01-01 12:22:59 +00:00
|
|
|
use Illuminate\Support\Facades\Input;
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
class IncidentController extends Controller
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
use ControllerTrait;
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2015-01-01 20:13:53 +00:00
|
|
|
/**
|
|
|
|
* The incident repository instance.
|
|
|
|
*
|
|
|
|
* @var \CachetHQ\Cachet\Repositories\Incident\IncidentRepository
|
|
|
|
*/
|
2014-12-01 12:03:32 +00:00
|
|
|
protected $incident;
|
|
|
|
|
2015-01-01 20:13:53 +00:00
|
|
|
/**
|
|
|
|
* Create a new incident controller instance.
|
|
|
|
*
|
|
|
|
* @param \CachetHQ\Cachet\Repositories\Incident\IncidentRepository $incident
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function __construct(IncidentRepository $incident)
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
$this->incident = $incident;
|
2014-11-27 16:36:24 +00:00
|
|
|
}
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2014-11-27 16:36:24 +00:00
|
|
|
/**
|
2014-12-30 18:19:22 +00:00
|
|
|
* Get all incidents.
|
2014-11-27 16:36:24 +00:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function getIncidents()
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
return $this->incident->all();
|
2014-11-27 16:36:24 +00:00
|
|
|
}
|
2014-11-26 16:08:47 +00:00
|
|
|
|
2014-11-27 16:36:24 +00:00
|
|
|
/**
|
2014-12-30 18:19:22 +00:00
|
|
|
* Get a single incident.
|
2014-11-27 16:36:24 +00:00
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
*
|
2015-01-01 20:13:53 +00:00
|
|
|
* @return \Incident
|
2014-11-27 16:36:24 +00:00
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function getIncident($id)
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
return $this->incident->findOrFail($id);
|
2014-11-27 16:36:24 +00:00
|
|
|
}
|
2014-11-26 16:08:47 +00:00
|
|
|
|
2014-11-27 16:36:24 +00:00
|
|
|
/**
|
2014-12-30 18:19:22 +00:00
|
|
|
* Create a new incident.
|
2014-11-27 16:36:24 +00:00
|
|
|
*
|
2015-01-01 20:13:53 +00:00
|
|
|
* @return \Incident
|
2014-11-27 16:36:24 +00:00
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function postIncidents()
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
return $this->incident->create($this->auth->user()->id, Input::all());
|
2014-11-27 16:36:24 +00:00
|
|
|
}
|
2014-11-26 15:00:36 +00:00
|
|
|
|
2014-11-27 16:36:24 +00:00
|
|
|
/**
|
2014-12-30 18:19:22 +00:00
|
|
|
* Update an existing incident.
|
2014-11-27 16:36:24 +00:00
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
*
|
2015-01-01 20:13:53 +00:00
|
|
|
* @return \Incident
|
2014-11-27 16:36:24 +00:00
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function putIncident($id)
|
|
|
|
{
|
2014-12-01 12:03:32 +00:00
|
|
|
return $this->incident->update($id, Input::all());
|
2014-11-27 16:36:24 +00:00
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|