Esempio n. 1
0
 /**
  * Show the form for editing the specified article.
  *
  * @param int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     try {
         $article = $this->repository->findById($id);
         $images = $this->uploader->getUrls($article->images->all(), '150');
         return $this->view('articles.edit', compact('article', 'images'));
     } catch (ModelNotFoundException $e) {
         return $this->redirectNotFound();
     }
 }
 /**
  * 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();
     }
 }
Esempio n. 3
0
 /**
  * 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();
     }
 }
Esempio n. 4
0
 /**
  * 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();
     }
 }