Exemplo n.º 1
0
 public function put($id, ArticleForm $request)
 {
     $article = Article::find($id);
     $title = $request->get('tieude');
     $mota = $request->get('mota');
     $noidung = $request->get('noidung');
     $image = $request->get('image');
     $article->update(['tieude' => $title, 'mota' => $mota, 'noidung' => $noidung, 'image' => $image]);
     return redirect()->route('view', $id);
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(ArticleForm $result, $id)
 {
     //
     try {
         $data = array('title' => $result->input('title'), 'user_id' => 9, 'cate_id' => $result->input('cate_id'), 'content' => $result->input('content'), 'tags' => $result->input('tags'));
         if (Article::isHasFile('pic')) {
             $data['pic'] = Article::uploadImg('pic');
         }
         if (Article::where('id', $id)->update($data)) {
             Notification::success('更新成功');
             // 清除缓存
             Cache::tags(Article::REDIS_ARTICLE_PAGE_TAG)->flush();
             Cache::forget(Article::REDIS_ARTICLE_CACHE . $id);
             return redirect()->route('backend.article.index');
         }
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(array('error' => $e->getMessage()))->withInput();
     }
 }