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';
     }
 }