public function index()
 {
     $activities = Activity::where('istop', 1)->where('states', 0)->orderBy('order_number')->get();
     $guides = Guide::where('isbest', '=', 1)->orderBy('orders')->take(6)->get();
     $topNotes = Note::topNotes()->with('user')->take(6)->get();
     //$users = User::topUsers()->take(10)->get();
     $adverts = Banner::where('tag', 'indexAdvert')->take(2)->get();
     $banners = Banner::where('tag', 'indexBanner')->orderBy('orders')->get();
     return view('index', compact('activities', 'guides', 'topNotes', 'adverts', 'banners'));
 }
 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');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $guide = GuideComment::findOrFail($id)->guide;
     GuideComment::destroy($id);
     Guide::updateCommentCount($guide);
     if ($request->has('redirect_to')) {
         return redirect($request->input('redirect_to'));
     }
 }
 public function favs($id)
 {
     $user = User::findOrFail($id);
     $guides = Guide::userFavs($id);
     return view('space.favs', compact('guides', 'user'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     Guide::destroy($id);
     return redirect($request->input('redirect_to'));
 }