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