Exemple #1
0
 /**
  * Storing All Users Post
  * @return [type] [description]
  */
 public function UsersNewsFeed(NewsFeed $request, User $user)
 {
     //Ignore
     $newsFeed = $request->except('_token');
     //For NewsFeed
     $username = $request->input('UserPosting');
     $usernameUpdate = $request->input('UserNameBeingUpdated');
     //For Timelines
     $userID = $request->input('UserPostingID');
     // For Single User posting
     $id = Redis::incr('total_post_id');
     Redis::hset('list_post_id', $username, $id);
     Redis::lpush('newsFeed' . ':' . $username, json_encode($newsFeed));
     // Cross Users Posting
     if ($usernameUpdate == true) {
         Redis::lpush('newsFeed' . ':' . $usernameUpdate, json_encode($newsFeed));
     }
     /**
      * Minor Bug.
      * If someone (who you're not following) posts on your newsfeed it should also show up on your timeline also
      */
     // Timeline
     Redis::lpush('timeline' . ':' . $userID, json_encode($newsFeed));
     $faveID = $user->favoriteeList();
     // Users Following Timeline
     if ($faveID == true) {
         foreach ($faveID as $id) {
             Redis::lpush('timeline:' . $id, json_encode($newsFeed));
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(NewsFeed $request, User $user, BaseNewsFeed $feed)
 {
     event(new FeedPosted($request->except('_token')));
     $feed->UsersNewsFeed($request, $user);
     // For sending email notification to Users
     $faveID = $user->favoriteeList();
     foreach ($faveID as $id) {
         $this->mail->sendNewNotificationToUsers($user->find($id), $request->input('UserPosting'));
     }
     session()->flash('success_message', 'Posted Successfully');
     return back();
 }