예제 #1
0
 /**
  * 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();
     }
 }
예제 #2
0
 /**
  * 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['type']);
         $data['user_id'] = \Auth::id();
         $data['slug'] = Str::slug($data['title']);
         $data['published_at'] = Carbon::now();
         $article->update($data);
         return isOnPages() ? $this->redirect('pages.index') : redirect()->route('admin.articles.edit', $article->id);
     } catch (ModelNotFoundException $e) {
         return $this->redirectNotFound();
     }
 }