public function feed() { $user_id = Auth::id(); // var_dump($user_id); $post = new Post(); $media = new Media(); $like = new Like(); $tag = new Tag(); $posts = $post->getFeed(); foreach ($posts as $key => $comment) { $posts[$key]->media = $media->getMediaFromAPI($comment->imdb_id); $posts[$key]->num_likes = $like->getNumLikes($comment->id); $posts[$key]->tags = $tag->getPostTags($comment->id); $posts[$key]->type = '<strong>comment</strong> and a <strong>rating</strong>'; // echo $posts[$key]->comment; // echo '<br>'; if ($posts[$key]->comment == '') { $posts[$key]->type = '<strong>rating</strong>'; } if (sizeof($posts[$key]->rating) === 0) { $posts[$key]->type = '<strong>comment</strong>'; } $likes_help = $like->getLikes($comment->id); $likes = array(); foreach ($likes_help as $k => $v) { $likes[$v->user_id] = $v->fname . ' ' . $v->lname; } // var_dump($likes); $posts[$key]->likes = $likes; $posts[$key]->post_date = date('M. d, Y', strtotime($posts[$key]->created_at)); } $view_data['posts'] = $posts; $view_data['side_nav_page'] = 'feed'; // var_dump($posts);exit; return View::make('feed', $view_data); }
/** * Display the specified resource. * * @param int $imdbId * @return Response */ public function show($imdbId) { $user_id = Auth::id(); // Media info $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://www.omdbapi.com/?apikey=40364d9f&i=' . $imdbId, CURLOPT_USERAGENT => 'Codular Sample cURL Request')); $media = json_decode(curl_exec($curl)); curl_close($curl); $media->ImageUrl = $media->Title . '-' . $media->Year . '.jpg'; $view_data['media'] = $media; // User info $queue_items = DB::table('queue_items')->select('imdb_id')->where('user_id', '=', $user_id)->get(); $view_data['queue_items'] = array(); foreach ($queue_items as $queue_item) { $view_data['queue_items'][] = $queue_item->imdb_id; } // Posts $posts = DB::table('posts')->select('*')->where('imdb_id', '=', $imdbId)->get(); $post = new Post(); $media = new Media(); $like = new Like(); $tag = new Tag(); $user = new User(); foreach ($posts as $key => $comment) { $posts[$key]->num_likes = $like->getNumLikes($comment->id); $posts[$key]->name = $user->getUserName($comment->user_id); $posts[$key]->tags = $tag->getPostTags($comment->id); $posts[$key]->type = '<strong>comment</strong> and a <strong>rating</strong>'; if ($posts[$key]->comment == '') { $posts[$key]->type = '<strong>rating</strong>'; } if (sizeof($posts[$key]->rating) === 0) { $posts[$key]->type = '<strong>comment</strong>'; } $likes_help = $like->getLikes($comment->id); $likes = array(); foreach ($likes_help as $k => $v) { $likes[$v->user_id] = $v->fname . ' ' . $v->lname; } $posts[$key]->likes = $likes; $posts[$key]->post_date = date('M. d, Y', strtotime($posts[$key]->created_at)); } $view_data['posts'] = $posts; // var_dump($view_data['posts']);exit; return View::make('media', $view_data); }