name, $component->description, Binput::get('status'), $component->link, $component->order, $component->group_id, $component->enabled )); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($component); } /** * Updates a components ordering. * * @return array */ public function postUpdateComponentOrder() { $componentData = Binput::get('ids'); foreach ($componentData as $order => $componentId) { try { $component = Component::find($componentId); dispatch(new UpdateComponentCommand( $component, $component->name, $component->description, $component->status, $component->link, $order + 1, $component->group_id, $component->enabled )); } catch (QueryException $e) { throw new BadRequestHttpException(); } } return $this->collection(Component::query()->orderBy('order')->get()); } /** * Updates the order of component groups. * * @return array */ public function postUpdateComponentGroupOrder() { $groupData = Binput::get('ids'); foreach ($groupData as $order => $groupId) { $group = ComponentGroup::find($groupId); dispatch(new UpdateComponentGroupCommand( $group, $group->name, $order + 1, $group->collapsed, $group->visible )); } return $this->collection(ComponentGroup::query()->orderBy('order')->get()); } /** * Returns a template by slug. * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return \CachetHQ\Cachet\Models\IncidentTemplate */ public function getIncidentTemplate() { $templateSlug = Binput::get('slug'); if ($template = IncidentTemplate::where('slug', '=', $templateSlug)->first()) { return $template; } throw new ModelNotFoundException("Incident template for $templateSlug could not be found."); } }