TimelineController.php 1.1 KB

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