check() ? 0 : 1; $incidents = Incident::where('visible', '>=', $incidentVisibility); $incidents->search(Binput::except(['sort', 'order', 'per_page'])); if ($sortBy = Binput::get('sort')) { $direction = Binput::has('order') && Binput::get('order') == 'desc'; $incidents->sort($sortBy, $direction); } $incidents = $incidents->paginate(Binput::get('per_page', 20)); return $this->paginator($incidents, Request::instance()); } /** * Get a single incident. * * @param \CachetHQ\Cachet\Models\Incident $incident * * @return \Illuminate\Http\JsonResponse */ public function getIncident(Incident $incident) { return $this->item($incident); } /** * Create a new incident. * * @return \Illuminate\Http\JsonResponse */ public function postIncidents() { try { $incident = dispatch(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []), Binput::get('meta', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); } /** * Update an existing incident. * * @param \CachetHQ\Cachet\Models\Incident $incident * * @return \Illuminate\Http\JsonResponse */ public function putIncident(Incident $incident) { try { $incident = dispatch(new UpdateIncidentCommand( $incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('stickied', false), Binput::get('occurred_at'), Binput::get('template'), Binput::get('vars', []) )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($incident); } /** * Delete an existing incident. * * @param \CachetHQ\Cachet\Models\Incident $incident * * @return \Illuminate\Http\JsonResponse */ public function deleteIncident(Incident $incident) { dispatch(new RemoveIncidentCommand($incident)); return $this->noContent(); } }