Ejemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function add()
 {
     $film = Input::get('film');
     $user = Input::get('user');
     $review = Input::get('review');
     $vote = Input::get('vote');
     $fbshare = Input::get('fbshare');
     $check = $this->reviewCheck($film);
     if ($check) {
     } else {
         if (!$review == "") {
             // inserts the review
             $rev = new Review();
             // revie instance
             $rev->fr_fl_id = $film;
             $rev->fr_usr_id = Auth::user()->id;
             $rev->fr_review = $review;
             $rev->fr_vote = $vote;
             $rev->fr_date = \time();
             $rev->save();
             // saves review
             // insert a new user actions
             $act = new Activity();
             // notification instance
             $act->type_id = '2';
             // activity type 2 for review
             $act->subject_id = Auth::user()->id;
             // id of the user
             $act->object_type = 'film';
             // type of object
             $act->object_id = $film;
             // id of the object
             $act->action_date = \time();
             // time of the activity
             $act->save();
             // saves activity
             //Deleting the rating action
             $delete = $this->deleteRatingAction($film);
             // Sending mails to all followers
             // Film id & review JSON
             $this->newReviewMail($film, $rev);
             //posts on fb if access token avaiable
             if ($fbshare) {
                 if (Auth::user()->fb_access_token) {
                     $fb = new FacebookController();
                     $execute = $fb->postFbReview($film, $review, $vote, Auth::user()->fb_uid, Auth::user()->fb_access_token, $fbshare);
                 }
             }
         }
     }
     // gets the review details from the given id
     $latest = DB::table('film_review')->where('fr_usr_id', Auth::user()->id)->orderBy('fr_id', 'desc')->first();
     $user = User::find(Auth::user()->id);
     return view('reviews.add', compact('latest', 'user'));
 }