Deleting of incidents

This commit is contained in:
James Brooks
2014-12-22 12:55:26 +00:00
parent 9e2da638f8
commit 37487ad653
3 changed files with 34 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ class DashIncidentController extends Controller
*/
public function showIncidents()
{
$incidents = Incident::all();
$incidents = Incident::orderBy('created_at', 'desc')->get();
return View::make('dashboard.incidents')->with([
'pageTitle' => 'Incidents - Dashboard',
@@ -61,4 +61,16 @@ class DashIncidentController extends Controller
return Redirect::back()->with('incident', $incident);
}
/**
* Deletes a given incident.
* @param Incident $incident
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteIncidentAction(Incident $incident)
{
$incident->delete();
return Redirect::back();
}
}

View File

@@ -16,6 +16,7 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function () {
Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashIncidentController@showIncidents']);
Route::get('incidents/add', ['as' => 'dashboard.incidents.add', 'uses' => 'DashIncidentController@showAddIncident']);
Route::post('incidents/add', 'DashIncidentController@createIncidentAction');
Route::get('incidents/{incident}/delete', 'DashIncidentController@deleteIncidentAction');
Route::get('incidents/template', ['as' => 'dashboard.incidents.template', 'uses' => 'DashIncidentController@showAddIncidentTemplate']);
Route::post('incidents/template', 'DashIncidentController@createIncidentTemplateAction');

View File

@@ -13,6 +13,26 @@
@else
<p class='lead'>You have <strong>{{ $incidents->count() }}</strong> incidents.</p>
@endif
<ul class='list-group'>
@foreach($incidents as $incident)
<li class='list-group-item'>
<div class='row'>
<div class='col-md-6'>
<strong>{{ $incident->name }}</strong>
@if($incident->message)
<p><small>{{ Str::words($incident->message, 5) }}</small></p>
@endif
</div>
<div class='col-md-6'>
<ul class='nav nav-pills pull-right'>
<li role='presentation'><a href='/dashboard/incidents/{{ $incident->id }}/delete' class='btn btn-danger'>Delete</a></li>
</ul>
</div>
</div>
</li>
@endforeach
</ul>
</div>
</div>
@stop