Deleting of incidents
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user