Ejemplo n.º 1
0
 public function getDisplayFeed(Request $request, $FeedID)
 {
     $user_id = \Auth::user()->id;
     # Get any articles which have been marked as read
     $readArticles = \p4\UserArticle::where('user_id', $user_id)->where('marked_as_read', 1)->pluck('article_id');
     $article_count = \p4\Article::where('feed_id', $FeedID)->count();
     # Retrieve articles for this feed and leave out the items which have been marked as read by the user
     $articles = \p4\Article::where('feed_id', $FeedID)->whereNotIn('id', $readArticles)->orderby('publish_date', 'DESC')->paginate(env('PAGE_SIZE', 50));
     $feed_name = \p4\UserFeed::where('feed_id', $FeedID)->where('user_id', $user_id)->first()->feed_name;
     return view('articles', ['title' => "News Stories from " . $feed_name . " (" . $article_count . " articles)", 'articles' => $articles, 'user_id' => $user_id]);
 }
Ejemplo n.º 2
0
 public function getRemoveFeed(Request $request, $feed_id)
 {
     $user_id = \Auth::user()->id;
     #Remove this Feed from the User_Feed Table if it exists
     $userFeed = \p4\UserFeed::where('feed_id', '=', $feed_id)->where('user_id', '=', $user_id)->first();
     if ($userFeed) {
         $userFeed->delete();
     }
     # Remove any Articles Marked for Deletion
     $articles = \p4\Article::where('feed_id', $feed_id)->pluck('id');
     $userFeedArticles = \p4\UserArticle::wherein('article_id', $articles)->where('user_id', '=', $user_id);
     if ($userFeedArticles) {
         $userFeedArticles->delete();
     }
     #Remove this Feed from the Feeds table if nobody else is subscribed to it
     if (!\p4\UserFeed::where('feed_id', '=', $feed_id)->exists()) {
         #Remove Articles First
         \p4\Article::where('feed_id', '=', $feed_id)->delete();
         #Now Remove the Feed
         $feed = \p4\Feed::where('id', '=', $feed_id)->first();
         if ($feed) {
             $feed->delete();
         }
     }
     # Update the Session Feeds so the updated list will appear in the left nav
     \p4\User::setSessionFeeds($user_id);
     return \Redirect::to('/Manage');
 }