示例#1
0
 public function unFavGuide($id)
 {
     $guideFav = GuideFav::where('user_id', Auth::user()->id)->where('guide_id', $id)->first();
     if ($guideFav != null) {
         $guide = Guide::findOrFail($id);
         $guideFav->delete();
         $guide->updateFavs();
     }
     return redirect(URL::previous());
 }
 public function storeComments(CommentRequest $request, $id)
 {
     $guide = Guide::findOrFail($id);
     $comment = new GuideComment();
     $comment->user_id = Auth::user()->id;
     $comment->content = ubbReplace($request->input('content'));
     $comment->guide_id = $id;
     $comment->save();
     Guide::updateCommentCount($guide);
     return redirect('guides/' . $id . '#comments');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(GuideRequest $request, $id)
 {
     $guide = Guide::findOrFail($id);
     $guide->update($request->all());
     $thumb = $request->file('thumb');
     $bannerThumb = $request->file('banner_thumb');
     $guide->saveThumbs($thumb, $bannerThumb);
     return redirect($request->input('redirect_to'));
 }