public function user_feed_name($user_id) { $feed_name = ""; if (\p4\UserFeed::where('user_id', $user_id)->where('feed_id', $this->feed_id)->exists()) { $feed_name = \p4\UserFeed::where('user_id', $user_id)->where('feed_id', $this->feed_id)->first()->feed_name; } return $feed_name; }
public static function setSessionFeeds($user_id) { # Set Feeds for this user in the Session Variable $feeds = \p4\UserFeed::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get(); $tags = \p4\Tag::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get(); $categories = \p4\Category::where('user_id', '=', $user_id)->orderby('weight', 'DESC')->get(); foreach ($feeds as $f) { $f->stats = $f->get_stats(); } foreach ($tags as $t) { $t->stats = $t->get_stats(); } \Session::forget('myfeeds'); \Session::forget('mytags'); \Session::forget('categories'); \Session::push('myfeeds', $feeds); \Session::push('mytags', $tags); \Session::push('categories', $categories); }
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]); }
public static function getFeeds($category_id) { return \p4\UserFeed::where('category_id', '=', $category_id)->get(); }
public function postUpdateFeed(Request $request) { $user_id = \Auth::user()->id; // Validate Edit Form Input $input = array('feed_name' => $request->input('edit-feed-name'), 'feed_weight' => $request->input('edit-feed-weight'), 'feed_category' => $request->input('edit-feed-category'), 'feed_id' => $request->input('edit-feed-id')); $validator = Validator::make($input, ['feed_name' => 'required|min:3|max:50', 'feed_weight' => 'required|integer|min:1|max:100', 'feed_category' => 'required|integer|min:0', 'feed_id' => 'required|integer|min:1']); if ($validator->fails()) { return redirect('/Manage')->withErrors($validator)->withInput(); } $feedName = $request->input('edit-feed-name'); $feedWeight = $request->input('edit-feed-weight'); $feedID = $request->input('edit-feed-id'); $categoryID = $request->input('edit-feed-category'); $updatedFeed = \p4\UserFeed::where('feed_id', '=', $feedID)->where('user_id', '=', $user_id)->first(); $updatedFeed->feed_name = $feedName; $updatedFeed->weight = $feedWeight; $updatedFeed->category_id = $categoryID; $updatedFeed->save(); # Update the Session Feeds so the updated list will appear in the left nav \p4\User::setSessionFeeds($user_id); return \Redirect::to('/Manage'); }