TimelineController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Auth;
  5. use App\{Follower, Status, User};
  6. class TimelineController extends Controller
  7. {
  8. public function __construct()
  9. {
  10. $this->middleware('auth');
  11. }
  12. public function personal()
  13. {
  14. // TODO: Use redis for timelines
  15. $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
  16. $following->push(Auth::user()->profile->id);
  17. $timeline = Status::whereIn('profile_id', $following)
  18. ->orderBy('id','desc')
  19. ->withCount(['comments', 'likes'])
  20. ->simplePaginate(20);
  21. $type = 'personal';
  22. return view('timeline.template', compact('timeline', 'type'));
  23. }
  24. public function local()
  25. {
  26. // TODO: Use redis for timelines
  27. // $timeline = Timeline::build()->local();
  28. $timeline = Status::whereHas('media')
  29. ->whereNull('in_reply_to_id')
  30. ->withCount(['comments', 'likes'])
  31. ->orderBy('id','desc')
  32. ->simplePaginate(20);
  33. $type = 'local';
  34. return view('timeline.template', compact('timeline', 'type'));
  35. }
  36. }