/** * Update the specified article in storage. * * @param int $id * @return Response */ public function update(Update $request, $id) { try { $article = $this->repository->findById($id); $data = $request->all(); unset($data['image']); unset($data['type']); if (\Input::hasFile('image')) { $article->deleteImage(); $this->uploader->upload('image')->save('images/articles'); $data['image'] = $this->uploader->getFilename(); } $data['user_id'] = \Auth::id(); $data['slug'] = Str::slug($data['title']); $article->update($data); return $this->redirect(isOnPages() ? 'pages.index' : 'articles.index'); } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } }
/** * Update the specified article in storage. * * @param int $id * @return Response */ public function update($id) { try { $article = $this->articles->findOrFail($id); app('Pingpong\\Admin\\Validation\\Article\\Update')->validate($data = $this->inputAll()); unset($data['image']); unset($data['type']); if (\Input::hasFile('image')) { $article->deleteImage(); $this->uploader->upload('image')->save('images/articles'); $data['image'] = $this->uploader->getFilename(); } $data['user_id'] = \Auth::id(); $data['slug'] = \Str::slug($data['title']); $article->update($data); return $this->redirect(isOnPages() ? 'pages.index' : 'articles.index'); } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } }
/** * Update the specified service in storage. * * @param int $id * * @return Response */ public function update(Update $request, $id) { try { $service = $this->repository->findById($id); $data = $request->all(); unset($data['image']); unset($data['type']); if (\Input::hasFile('image')) { $service->deleteImage(); $this->uploader->upload('image')->save('images/services'); $data['image'] = $this->uploader->getFilename(); } $data['user_id'] = \Auth::id(); $service->update($data); $service->updatePrices($id, $data); $service->updatePackages($id, $data); return $this->redirect('services.index'); } catch (ModelNotFoundException $e) { return $this->redirectNotFound(); } }