Delete components via link

This commit is contained in:
James Brooks
2014-12-13 13:50:21 +00:00
parent 582742f8fe
commit 51fedb8b82
3 changed files with 20 additions and 1 deletions

View File

@@ -9,6 +9,10 @@ class DashboardController extends Controller {
return View::make('dashboard.index');
}
/**
* Creates a new incident.
* @return \Illuminate\Http\RedirectResponse
*/
public function createIncidentAction() {
$_incident = Input::get('incident');
$incident = Incident::create($_incident);
@@ -29,6 +33,10 @@ class DashboardController extends Controller {
]);
}
/**
* Creates a new component.
* @return \Illuminate\Http\RedirectResponse
*/
public function createComponentAction() {
$_component = Input::get('component');
$component = Component::create($_component);
@@ -36,6 +44,16 @@ class DashboardController extends Controller {
return Redirect::back()->with('component', $component);
}
/**
* Deletes a given component.
* @param Component $component
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteComponentAction(Component $component) {
$component->delete();
return Redirect::back();
}
/**
* Shows the incidents view.
* @return \Illuminate\View\View

View File

@@ -6,6 +6,7 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
Route::get('components', ['as' => 'dashboard.components', 'uses' => 'DashboardController@showComponents']);
Route::post('components/create', 'DashboardController@createComponentAction');
Route::get('components/{component}/delete', 'DashboardController@deleteComponentAction');
Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashboardController@showIncidents']);
Route::get('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']);

View File

@@ -17,7 +17,7 @@
<div class='col-md-6'>
<ul class='nav nav-pills'>
<li role='presentation'><a href='javascript: void(0);'>Edit</a></li>
<li role='presentation'><a href='javascript: void(0);'>Delete</a></li>
<li role='presentation'><a href='/dashboard/components/{{ $component->id }}/delete'>Delete</a></li>
</ul>
</div>
</div>