2014-12-20 18:53:52 +00:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 00:18:19 +00:00
|
|
|
namespace CachetHQ\Cachet\Http\Controllers;
|
2015-01-01 15:45:04 +00:00
|
|
|
|
2015-01-02 00:18:19 +00:00
|
|
|
use CachetHQ\Cachet\Models\Incident;
|
|
|
|
use CachetHQ\Cachet\Models\IncidentTemplate;
|
2015-01-02 12:05:50 +00:00
|
|
|
use GrahamCampbell\Binput\Facades\Binput;
|
2015-01-01 16:18:24 +00:00
|
|
|
use Illuminate\Routing\Controller;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Illuminate\Support\Facades\Redirect;
|
|
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
class DashIncidentController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Shows the incidents view.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showIncidents()
|
|
|
|
{
|
2014-12-22 12:55:26 +00:00
|
|
|
$incidents = Incident::orderBy('created_at', 'desc')->get();
|
2014-12-20 21:20:17 +00:00
|
|
|
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.incidents.index')->with([
|
2015-01-05 11:12:34 +00:00
|
|
|
'pageTitle' => trans('dashboard.incidents.incidents').' - '.trans('dashboard.dashboard'),
|
2014-12-20 21:20:17 +00:00
|
|
|
'incidents' => $incidents,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the add incident view.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showAddIncident()
|
|
|
|
{
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.incidents.add')->with([
|
2015-01-05 11:12:34 +00:00
|
|
|
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
|
2014-12-20 21:20:17 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the add incident template view.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showAddIncidentTemplate()
|
|
|
|
{
|
2015-01-05 11:12:34 +00:00
|
|
|
return View::make('dashboard.incidents.templates.add')->with([
|
|
|
|
'pageTitle' => trans('dashboard.incidents.templates.add.title').' - '.trans('dashboard.dashboard'),
|
2014-12-20 21:20:17 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new incident template.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
|
|
|
public function createIncidentTemplateAction()
|
|
|
|
{
|
2015-01-02 12:05:50 +00:00
|
|
|
$_template = Binput::get('template');
|
2014-12-20 21:20:17 +00:00
|
|
|
$template = IncidentTemplate::create($_template);
|
|
|
|
|
|
|
|
return Redirect::back()->with('template', $template);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new incident.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
|
|
|
public function createIncidentAction()
|
|
|
|
{
|
2015-01-09 19:48:28 +00:00
|
|
|
$incident = Incident::create(Binput::get('incident'));
|
2014-12-20 21:20:17 +00:00
|
|
|
|
2015-01-09 19:48:28 +00:00
|
|
|
return Redirect::back()->withInput(Binput::all())->with('incident', $incident);
|
2014-12-20 21:20:17 +00:00
|
|
|
}
|
2014-12-22 12:55:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a given incident.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2015-01-02 00:18:19 +00:00
|
|
|
* @param \CachetHQ\Cachet\Models\Incident $incident
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-22 12:55:26 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
|
|
|
public function deleteIncidentAction(Incident $incident)
|
|
|
|
{
|
|
|
|
$incident->delete();
|
|
|
|
|
|
|
|
return Redirect::back();
|
|
|
|
}
|
2015-01-02 20:35:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the edit incident view.
|
|
|
|
*
|
|
|
|
* @param \CachetHQ\Cachet\Models\Incident $incident
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showEditIncidentAction(Incident $incident)
|
|
|
|
{
|
|
|
|
return View::make('dashboard.incidents.edit')->with([
|
2015-01-05 11:12:34 +00:00
|
|
|
'pageTitle' => trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'),
|
2015-01-03 17:22:00 +00:00
|
|
|
'incident' => $incident,
|
2015-01-02 20:35:02 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit an incident.
|
|
|
|
*
|
|
|
|
* @param \CachetHQ\Cachet\Models\Incident $incident
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
|
|
|
public function editIncidentAction(Incident $incident)
|
|
|
|
{
|
|
|
|
$_incident = Binput::get('incident');
|
|
|
|
$incident->update($_incident);
|
|
|
|
|
|
|
|
return Redirect::to('dashboard/incidents');
|
|
|
|
}
|
2014-12-20 18:53:52 +00:00
|
|
|
}
|