/** * Updates a component with the entered info. * * @param \CachetHQ\Cachet\Models\Component $component * * @throws \Exception * * @return \CachetHQ\Cachet\Models\Component */ public function postUpdateComponent(Component $component) { if (!$component->update(Binput::except(['_token']))) { throw new Exception(trans('dashboard.components.edit.failure')); } return $component; }
/** * Updates a component with the entered info. * * @param \CachetHQ\Cachet\Models\Component $component * * @throws \Exception * * @return \CachetHQ\Cachet\Models\Component */ public function postUpdateComponent(Component $component) { if (!$component->update(Binput::except(['_token']))) { throw new Exception('Failed to update the component.'); } return $component; }
/** * Update an existing component. * * @param \CachetHQ\Cachet\Models\Componet $component * * @return \CachetHQ\Cachet\Models\Component */ public function putComponent(Component $component) { $component->update(Binput::except('tags')); if (!$component->isValid('updating')) { throw new BadRequestHttpException(); } if (Binput::has('tags')) { $tags = preg_split('/ ?, ?/', Binput::get('tags')); // For every tag, do we need to create it? $componentTags = array_map(function ($taggable) use($component) { return Tag::firstOrCreate(['name' => $taggable])->id; }, $tags); $component->tags()->sync($componentTags); } return $this->item($component); }
/** * Updates a component. * * @param \CachetHQ\Cachet\Models\Component $component * * @return \Illuminate\Http\RedirectResponse */ public function updateComponentAction(Component $component) { $_component = Binput::get('component'); $tags = array_pull($_component, 'tags'); try { $component->update($_component); } catch (ValidationException $e) { return Redirect::route('dashboard.components.edit', ['id' => $component->id])->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))->withErrors($e->getMessageBag()); } // The component was added successfully, so now let's deal with the tags. $tags = preg_split('/ ?, ?/', $tags); // For every tag, do we need to create it? $componentTags = array_map(function ($taggable) use($component) { return Tag::firstOrCreate(['name' => $taggable])->id; }, $tags); $component->tags()->sync($componentTags); return Redirect::route('dashboard.components.edit', ['id' => $component->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success'))); }
/** * Updates a component. * * @param \CachetHQ\Cachet\Models\Component $component * * @return \Illuminate\Http\RedirectResponse */ public function updateComponentAction(Component $component) { $_component = Binput::get('component'); $tags = array_pull($_component, 'tags'); $component->update($_component); if (!$component->isValid()) { return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.components.edit.failure')))->with('errors', $component->getErrors()); } // The component was added successfully, so now let's deal with the tags. $tags = preg_split('/ ?, ?/', $tags); // For every tag, do we need to create it? $componentTags = array_map(function ($taggable) use($component) { return Tag::firstOrCreate(['name' => $taggable])->id; }, $tags); $component->tags()->sync($componentTags); $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.edit.success')); return Redirect::back()->with('success', $successMsg); }
/** * Updates a component. * * @param \CachetHQ\Cachet\Models\Component $component * * @return \Illuminate\Http\RedirectResponse */ public function updateComponentAction(Component $component) { $_component = Binput::get('component'); $component->update($_component); return Redirect::back()->with('savedComponent', $component); }