Incidents will now be removed via the command

This commit is contained in:
James Brooks 2015-08-26 13:21:23 +01:00
parent b80b53191b
commit 7be3aa2552
2 changed files with 10 additions and 2 deletions

View File

@ -11,16 +11,20 @@
namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
use CachetHQ\Cachet\Models\Incident;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class IncidentController extends AbstractApiController
{
use DispatchesJobs;
/**
* Get all incidents.
*
@ -122,7 +126,7 @@ class IncidentController extends AbstractApiController
*/
public function deleteIncident(Incident $incident)
{
$incident->delete();
$this->dispatch(new RemoveIncidentCommand($incident));
return $this->noContent();
}

View File

@ -12,6 +12,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Component;
@ -19,6 +20,7 @@ use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
@ -27,6 +29,8 @@ use Jenssegers\Date\Date;
class IncidentController extends Controller
{
use DispatchesJobs;
/**
* Stores the sub-sidebar tree list.
*
@ -208,7 +212,7 @@ class IncidentController extends Controller
*/
public function deleteIncidentAction(Incident $incident)
{
$incident->delete();
$this->dispatch(new RemoveIncidentCommand($incident));
return Redirect::route('dashboard.incidents.index');
}