update(Binput::except(['_token']))) { throw new Exception(trans('dashboard.components.edit.failure')); } return $component; } /** * Updates a components ordering. * * @return array */ public function postUpdateComponentOrder() { $componentData = Binput::get('ids'); foreach ($componentData as $order => $componentId) { // Ordering should be 1-based, data comes in 0-based Component::find($componentId)->update(['order' => $order + 1]); } return $componentData; } /** * Updates the order of component groups. * * @return array */ public function postUpdateComponentGroupOrder() { $groupData = Binput::get('ids'); foreach ($groupData as $order => $groupId) { ComponentGroup::find($groupId)->update(['order' => $order + 1]); } return $groupData; } /** * 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."); } /** * Checks if Cachet is up to date. * * @return \Illuminate\Http\JsonResponse */ public function checkVersion() { $latest = app(Releases::class)->latest(); return Response::json([ 'cachet_version' => CACHET_VERSION, 'latest_version' => $latest, 'is_latest' => version_compare(CACHET_VERSION, $latest) === 1, ]); } }