Inheritance: extends Controller
Ejemplo n.º 1
0
 /**
  * User follow 
  *
  * @param  int  $id
  * @return Response
  */
 public function follow()
 {
     $user = Input::get('user');
     $follow = $this->followCheck($user);
     $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';
     if ($follow) {
     } else {
         $query = DB::table('user_friends')->insertGetId(array('friend_user_id' => $user, 'follower_user_id' => Auth::user()->id));
         // creating a notification
         $noti = new Notification();
         // notification instance
         $noti->user_id = $user;
         // 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();
         // saves notification
         /// 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 = $user;
         // id of the review in picture
         $act->action_date = \time();
         // default '0' as it is unread
         $act->save();
         // saves activity
         $mail = $this->newFollowMail($user);
     }
     $username = DB::table('users')->where('id', $user)->first();
     if (Auth::user()->fb_access_token) {
         $fb = new FacebookController();
         $execute = $fb->postFbFollow($username->username, Auth::user()->fb_uid, Auth::user()->fb_access_token);
     }
     if ($query) {
         return 'true';
     } else {
         return 'false';
     }
 }
Ejemplo n.º 2
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'));
 }
Ejemplo n.º 3
0
 public function postUpload(Request $request)
 {
     $this->validate($request, ['image1' => 'required|image', 'image2' => 'image', 'image3' => 'image', 'image4' => 'image']);
     $media_files = [$request->file('image1')];
     if ($request->hasFile('image2') && $request->file('image2')->isValid()) {
         $media_files[] = $request->file('image2');
     }
     if ($request->hasFile('image3') && $request->file('image3')->isValid()) {
         $media_files[] = $request->file('image3');
     }
     if ($request->hasFile('image4') && $request->file('image4')->isValid()) {
         $media_files[] = $request->file('image4');
     }
     $media_ids = [];
     foreach ($media_files as $file) {
         $result = $this->api->media_upload(['media' => $file]);
         $error = $this->citcuit->parseError($result);
         if ($error) {
             return view('error', $error);
         }
         $media_ids[] = $result->media_id_string;
     }
     if ($request->has('fb')) {
         $fb = new FacebookController();
         $fb->loadToken();
         $fb->postImage($request->input('tweet'), $media_files);
     }
     $media_ids = implode(',', $media_ids);
     $param = ['status' => $request->input('tweet'), 'media_ids' => $media_ids];
     $result = $this->api->statuses_update($param);
     $error = $this->citcuit->parseError($result);
     if ($error) {
         return view('error', $error);
     }
     return redirect('/');
 }