public function __construct() { // Kill middleware defined by ParentController. // $this->middleware = []; $this->middleware('throttle.api:10,1'); parent::__construct(); }
public function __construct() { // Kill middleware defined by ParentController. $this->middleware = []; parent::__construct(); }
public function testFailUpdateLocationsUndefinedUser() { $request = $this->createRequestForTest($this->addMethodOntoRequest()); $controller = new Controllers\UsersController(); $this->setExpectedException('ErrorException'); $controller->updateLocations(0, $request); }
public function newReviewMail($film, $review) { //Get All Followers of the loggedn in user $users = new UsersController(); $followers = $users->getFollower(Auth::user()->id); $movie = Movie::where('fl_id', $film)->first(); foreach ($followers as $subject) { // if the subject is 1 or greater than 200 to avoid spam mail if ($subject->id > 200 || $subject->id == 1) { //The follower to whom this email will be sent $user = User::where('id', $subject->id)->first(); if ($movie->fl_image) { $filmImage = 'http://www.berdict.com/public/uploads/movie/' . $movie->fl_year . '/' . $movie->fl_image; } else { $filmImage = 'http://www.berdict.com/public/berdict/img/default_poster.jpg'; } $filmUrl = 'http://www.berdict.com/movie/' . $movie->fl_id . '/' . Common::cleanUrl($movie->fl_name); $subjectEmail = $user->usr_email; $subjectName = $user->usr_fname . ' ' . $user->usr_lname; $emailSubject = 'Hey ' . $user->usr_fname . '! Your friend ' . Auth::user()->usr_fname . ' ' . Auth::user()->usr_lname . ' wrote a review for ' . $movie->fl_name; $data = array('subjectName' => $user->usr_fname, 'filmName' => $movie->fl_name, 'filmYear' => $movie->fl_year, 'filmUrl' => $filmUrl, 'filmImage' => $filmImage, 'filmReview' => $review->fr_review, 'reviewId' => $review->fr_id, 'objectId' => Auth::user()->id, 'objectName' => Auth::user()->usr_fname . ' ' . Auth::user()->usr_lname, 'objectUsername' => Auth::user()->username, 'filmName' => $movie->fl_name); Mail::send('emails.newReview', $data, function ($message) use($subjectEmail, $subjectName, $emailSubject) { $message->to($subjectEmail, $subjectName); $message->subject($emailSubject); $message->from('*****@*****.**', 'Berdict'); }); } } }
public function followAll() { $subject_type = 'user'; // always user, the user who triggered this notification $subject_id = Auth::user()->id; // id of the user who triggered the notification $object_type = 'user'; $object_id = Auth::user()->id; $type = 'follow'; $friend = DB::table('user_facebook')->where('ufb_usr_id', Auth::user()->id)->join('users', 'users.oauth_id', '=', 'user_facebook.ufb_friend_id')->get(); foreach ($friend as $friend) { // check if already following $follow = $this->followCheck($friend->id); if ($follow) { // if not then follow } else { $query = DB::table('user_friends')->insertGetId(array('friend_user_id' => $friend->id, 'follower_user_id' => Auth::user()->id)); // creating a notification $noti = new Notification(); // notification instance $noti->user_id = $friend->id; // the user who will get this notification $noti->subject_type = $subject_type; // user $noti->subject_id = $subject_id; // the uset who liked the review $noti->object_type = $object_type; // object is review $noti->object_id = $object_id; // id of the review in picture $noti->type = $type; // liked - notification type $noti->read = '0'; // default '0' as it is unread $noti->time = \time(); // default '0' as it is unread $noti->save(); // insert into the user actions $act = new Activity(); // notification instance $act->type_id = '4'; // the user who will get this notification $act->subject_id = $subject_id; // user $act->object_type = 'user'; // object is review $act->object_id = $friend->id; // id of the review in picture $act->action_date = \time(); // default '0' as it is unread $act->save(); // saves activity $mail = new UsersController(); $mail->newFollowMail($friend->id); } } }
/** * 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 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')); } }