コード例 #1
0
 /**
  * Lists all undeleted notifications per user and updates status to UNREAD on NEW notifications
  * route: notifications/view
  *
  * @return Response
  */
 public static function viewAction()
 {
     $status = Input::get('status', CONSTANTS::NOTIFICATION_STATUS_READ);
     $user_id_to = Input::get('user_id_to', null);
     $current_page = Input::get('page', CONSTANTS::FIRST_PAGE);
     $order = Input::get('orderby', CONSTANTS::ORDER_DESC);
     $data = array();
     if ($order != CONSTANTS::ORDER_DESC) {
         $order = CONSTANTS::ORDER_ASC;
     }
     $notifications = Notification::getNotificationByUserToCustomPaginate($status, $order, $user_id_to, $current_page);
     foreach ($notifications as $notification) {
         $data[] = $notification;
     }
     $page = array(KeyParser::current => $notifications->currentPage(), KeyParser::number => $notifications->lastPage());
     $json_return = array(KeyParser::data => $data, KeyParser::page => $page);
     return response()->json($json_return);
 }
コード例 #2
0
ファイル: Users.php プロジェクト: jigen7/laravel5
 /**
  * Get the review, checkin, bookmark, follow, photos, comments, and notification data of a user
  *
  * @param $id
  * @param $viewer_id
  * @return array
  */
 public static function getStatistics($id, $viewer_id = false)
 {
     $user = self::find($id);
     if (!$user) {
         return array();
     }
     $user_array = ModelFormatter::userLongFormat($user);
     $user_array[KeyParser::review_count] = Reviews::getCountByUserId($id);
     $user_array[KeyParser::checkin_count] = CheckIns::getCountByUserId($id);
     $user_array[KeyParser::bookmark_count] = Bookmarks::getCountByUserId($id);
     $user_array[KeyParser::following_count] = Follow::getCountByUserId($id, CONSTANTS::FOLLOW_FOLLOWED);
     $user_array[KeyParser::follower_count] = Follow::getCountByUserId($id, CONSTANTS::FOLLOW_FOLLOWER);
     $user_array[KeyParser::photo_count] = Photos::getCountByUserId($id);
     $user_array[KeyParser::comment_count] = Comments::getCountByUserId($id);
     $user_array[KeyParser::unread_notification_count] = Notification::getNotificationByUserToCustomPaginate(CONSTANTS::NOTIFICATION_STATUS_UNREAD, CONSTANTS::ORDER_DESC, $id, null, true);
     $user_array[KeyParser::new_notification_count] = Notification::getNotificationByUserToCustomPaginate(CONSTANTS::NOTIFICATION_STATUS_NEW, CONSTANTS::ORDER_DESC, $id, null, true);
     if ($viewer_id) {
         $user_array[KeyParser::is_followed_by_viewer] = Follow::isFollowed($viewer_id, $id);
     }
     return $user_array;
 }