1
0

TimelineController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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::whereHas('media')
  18. ->whereNull('in_reply_to_id')
  19. ->whereIn('profile_id', $following)
  20. ->orderBy('id','desc')
  21. ->withCount(['comments', 'likes'])
  22. ->simplePaginate(10);
  23. return view('timeline.personal', compact('timeline'));
  24. }
  25. public function local()
  26. {
  27. // TODO: Use redis for timelines
  28. $timeline = Status::whereHas('media')
  29. ->whereNull('in_reply_to_id')
  30. ->orderBy('id','desc')
  31. ->withCount(['comments', 'likes'])
  32. ->simplePaginate(10);
  33. return view('timeline.public', compact('timeline'));
  34. }
  35. }