/**
  * @param array $data
  *
  * @return Notification
  */
 public function create($data)
 {
     $notification = new Notification();
     $notification->setName(Notification::LEADER_FOLLOWS);
     $notification->setContent(array('follower' => $data['follower'], 'followerFullName' => $data['followerFullName'], 'leader' => $data['leader'], 'leaderFullName' => $data['leaderFullName'], 'image' => $data["followerImage"]));
     $followersIds = $this->userRepository->getFollowersIds($data['follower']);
     $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['followerFullName'], '%leader%' => $data['leaderFullName']));
     $notification->setMessage($translatedMessage);
     foreach ($followersIds as $followerId) {
         $this->addPushMessage($notification, $followerId);
     }
     return $notification;
 }
 /**
  * @param array $data
  *
  * @return Notification
  */
 public function create($data)
 {
     $userId = $data['user'];
     $reviewId = $data['review'];
     $notification = new Notification();
     $notification->setName(Notification::LEADER_REVIEW);
     $notification->setContent(array('review' => $reviewId, 'restaurant' => $data['restaurant'], 'restaurantName' => $data['restaurantName'], 'user' => $data['user'], 'userFullName' => $data['userFullName'], 'image' => $data['image']));
     $translatedMessage = $this->translator->trans($notification->getTranslationKey(), array('%name%' => $data['userFullName'], '%restaurant%' => $data['restaurantName']));
     $notification->setMessage($translatedMessage);
     $followersIds = $this->userRepository->getFollowersIds($userId);
     foreach ($followersIds as $followersId) {
         $this->addPushMessage($notification, $followersId);
     }
     return $notification;
 }
 /**
  * All my reviews in common with my followers' reviews of the last week
  * @param $userId
  *
  * @return int
  */
 public function getLastWeekCommonReviewsCount($userId)
 {
     $followerIds = $this->userRepository->getFollowersIds($userId);
     $sql = 'SELECT COUNT(*) as counter
         FROM (
             SELECT reviews.id, reviews.restaurant_id
             FROM reviews
             WHERE reviews.user_id = ?) my_reviews
         INNER JOIN (
             SELECT reviews.id, reviews.restaurant_id
             FROM reviews
             WHERE reviews.user_id IN (?)
             AND reviews.created > DATE_SUB(NOW(), INTERVAL 1 WEEK)) follower_reviews
         ON my_reviews.restaurant_id = follower_reviews.restaurant_id';
     $result = $this->connection->fetchArray($sql, array($userId, $followerIds), array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY));
     return (int) $result[0];
 }