/** * Display the specified resource. * * @param int $id * @return Response */ public function show($user_id) { $post = new Post(); $media = new Media(); $like = new Like(); $follow = new Follow(); $tag = new Tag(); $comments = $post->getUserComments($user_id); foreach ($comments as $key => $comment) { $comments[$key]->media = $media->getMediaFromAPI($comment->imdb_id); $comments[$key]->num_likes = $like->getNumLikes($comment->id); $comments[$key]->tags = $tag->getPostTags($comment->id); $likes_help = $like->getLikes($comment->id); $likes = array(); foreach ($likes_help as $k => $v) { $likes[$v->user_id] = $v->fname . ' ' . $v->lname; } $comments[$key]->likes = $likes; } $ratings = $post->getUserRatings($user_id); foreach ($ratings as $key => $rating) { $ratings[$key]->media = $media->getMediaFromAPI($rating->imdb_id); $ratings[$key]->num_likes = $like->getNumLikes($rating->id); $ratings[$key]->tags = $tag->getPostTags($rating->id); $likes_help = $like->getLikes($rating->id); $likes = array(); foreach ($likes_help as $k => $v) { $likes[$v->user_id] = $v->fname . ' ' . $v->lname; } $ratings[$key]->likes = $likes; } $view_data['user'] = User::find($user_id); $view_data['user']['num_followers'] = $follow->getNumFollowers($user_id); $view_data['comments'] = $comments; $view_data['ratings'] = $ratings; $view_data['followers'] = $follow->getFollowers($user_id); $view_data['following'] = $follow->getFollowing($user_id); $view_data['user']['num_following'] = sizeof($view_data['following']); if (Auth::id() == $user_id) { $view_data['side_nav_page'] = 'myprofile'; } else { $follow = new Follow(); $view_data['is_following'] = $follow->isFollowing(Auth::id(), $user_id); } // var_dump($view_data['following']);exit; return View::make('profile', $view_data); }