/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $movie = DB::table('film')->where('fl_id', $id)->first(); $movieRating = $this->betterRating($id, $movie->fl_rating); if (Auth::check()) { $ser = new UsersController(); $following = $ser->getFollowing(Auth::user()->id); $myReview = $this->myReview($id); if ($following) { $column = array(); foreach ($following as $following) { $column[] = $following->id; } $reviewCount = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->whereNotIn('fr_usr_id', $column)->WhereNotIn('fr_usr_id', array(Auth::user()->id))->count(); $frreviews = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->wherein('fr_usr_id', $column)->take(10)->get(); $reviews = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->whereNotIn('fr_usr_id', $column)->WhereNotIn('fr_usr_id', array(Auth::user()->id))->take(5)->orderBy('fr_date')->get(); } else { $frreviews = array(); $reviews = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->take(10)->orderBy('fr_date')->get(); $reviewCount = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->count(); } } else { $reviewCount = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->count(); $myReview = ""; $frreviews = array(); $reviews = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $id)->take(10)->orderBy('fr_date')->get(); } foreach ($reviews as $view) { $views = ++$view->fr_views; DB::table('film_review')->where('fr_id', $view->fr_id)->update(array('fr_views' => $views)); } foreach ($frreviews as $view) { $views = ++$view->fr_views; DB::table('film_review')->where('fr_id', $view->fr_id)->update(array('fr_views' => $views)); } if (Auth::check()) { $critics = $this->getCritics(Auth::user()->id); } else { $critics; } if (Auth::check()) { $commonFav = $this->getCommonFav($id); } else { $commonFav; } $rate = '0'; if (Auth::check()) { $user = Auth::user()->id; $watch = DB::table('user_watchlist')->where('uw_fl_id', $id)->where('uw_usr_id', Auth::user()->id)->first(); $rating = DB::table('rating')->where('rt_fl_id', $id)->where('rt_usr_id', Auth::user()->id)->first(); if ($rating) { $rate = $rating->rt_vote; } if ($watch) { $watch = '1'; } else { $watch = '0'; } $watchModel = new WatchedController(); $watched = $watchModel->watchCheck($id, Auth::user()->id); if ($watched) { $watched = '1'; } else { $watched = '0'; } $fav = DB::table('user_fav')->where('fav_fl_id', $id)->where('fav_usr_id', Auth::user()->id)->first(); if ($fav) { $fav = '1'; } else { $fav = '0'; } } else { $watch = '3'; $fav = '3'; $user = ''; } // Invoking that non-static method. $home = new HomeController(); $recent = $home->RecentMovies(7); if ($movie->fl_stars) { $count = substr_count($movie->fl_stars, ","); $first = ""; $second = ""; $third = ""; if ($count == 0) { $comma = explode(", ", $movie->fl_stars); $first = '%' . $comma[0] . '%'; $second = ""; $third = ""; } else { if ($count == 1) { $comma = explode(", ", $movie->fl_stars); $first = '%' . $comma[0] . '%'; $second = '%' . $comma[1] . '%'; $third = ""; } else { if ($count == 2) { $comma = explode(", ", $movie->fl_stars); $first = '%' . $comma[0] . '%'; $second = '%' . $comma[1] . '%'; $third = '%' . $comma[2] . '%'; } } } $sugg = DB::table('film')->orWhere('fl_stars', 'LIKE', $first)->orWhere('fl_stars', 'LIKE', $second)->orWhere('fl_stars', 'LIKE', $third)->where('fl_rating', '>', 6)->take(6)->orderBy(DB::raw('RAND()'))->get(); } else { $sugg = array(); } return view('movies.show', compact('myReview', 'frreviews', 'watchCount', 'favCount', 'commonFav', 'critics', 'movie', 'movieRating', 'sugg', 'reviews', 'reviewCount', 'recent', 'watch', 'fav', 'user', 'rate', 'watched')); }
public function loadMore() { $skip = Input::get('count'); $film = Input::get('film'); if (Auth::check()) { $ser = new UsersController(); $following = $ser->getFollowing(Auth::user()->id); $column = array(); foreach ($following as $following) { $column[] = $following->id; } $review = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $film)->whereNotIn('fr_usr_id', $column)->WhereNotIn('fr_usr_id', array(Auth::user()->id))->skip($skip)->take(5)->orderBy('fr_date')->get(); } else { $review = DB::table('film_review')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->where('fr_fl_id', $film)->skip($skip)->take(5)->orderBy('fr_date')->get(); } return view('reviews.more', compact('review')); }
public function newTest() { if (Auth::check()) { $Movies = new MoviesController(); $critics = $Movies->getCritics(Auth::user()->id); $home = new HomeController(); $recent = DB::table('film')->select('fl_id', 'fl_name', 'fl_image', 'fl_year', 'fl_stars', 'fl_genre', 'fl_outline', 'fl_dir_ar_id', 'fl_releasedate')->take(10)->orderBy('fl_release_date', 'desc')->whereRaw('fl_id NOT IN (select fs_fl_id from film_spotlight)')->get(); $other = DB::table('film')->select('fl_id', 'fl_name', 'fl_image', 'fl_year', 'fl_stars', 'fl_genre', 'fl_outline', 'fl_dir_ar_id', 'fl_releasedate')->take(20)->orderBy('fl_release_date', 'desc')->get(); // gets the user details fro username $friends = DB::table('user_actions')->leftjoin('user_friends', 'user_friends.friend_user_id', '=', 'user_actions.subject_id')->join('users', 'users.id', '=', 'user_actions.subject_id')->where('follower_user_id', Auth::user()->id)->take('40')->orderBy('action_date', 'desc')->get(); $User = new UsersController(); $following = $User->getFollowing(Auth::user()->id); $column = array(); foreach ($following as $following) { $column[] = $following->id; } if ($following) { $friend = DB::table('user_actions')->join('users', 'users.id', '=', 'user_actions.subject_id')->wherein('user_actions.subject_id', $column)->orWhere('user_actions.subject_id', Auth::user()->id)->take('40')->orderBy('action_date', 'desc')->get(); } else { $friend = DB::table('user_actions')->join('users', 'users.id', '=', 'user_actions.subject_id')->orWhere('user_actions.subject_id', Auth::user()->id)->take('40')->orderBy('action_date', 'desc')->get(); } return view('users.feed', compact('friend', 'critics', 'recent', 'other')); } else { $Movies = new MoviesController(); $critics = array(); $home = new HomeController(); $recent = DB::table('film')->select('fl_id', 'fl_name', 'fl_image', 'fl_year', 'fl_stars', 'fl_genre', 'fl_outline', 'fl_dir_ar_id', 'fl_releasedate')->take(10)->orderBy('fl_release_date', 'desc')->whereRaw('fl_id NOT IN (select fs_fl_id from film_spotlight)')->get(); $other = DB::table('film')->select('fl_id', 'fl_name', 'fl_image', 'fl_year', 'fl_stars', 'fl_genre', 'fl_outline', 'fl_dir_ar_id', 'fl_releasedate')->take(20)->orderBy('fl_release_date', 'desc')->get(); // gets the user details fro username $friends = DB::table('user_actions')->leftjoin('user_friends', 'user_friends.friend_user_id', '=', 'user_actions.subject_id')->join('users', 'users.id', '=', 'user_actions.subject_id')->take('40')->orderBy('action_date', 'desc')->get(); $review = DB::table('film_review')->join('film', 'film.fl_id', '=', 'film_review.fr_fl_id')->join('users', 'users.id', '=', 'film_review.fr_usr_id')->take('6')->get(); return View::make('new', compact('review', 'critics', 'recent', 'other')); } }