TimelineController.php 887 B

12345678910111213141516171819202122232425262728293031
  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')->whereNull('in_reply_to_id')->whereIn('profile_id', $following)->orderBy('id','desc')->simplePaginate(10);
  17. return view('timeline.personal', compact('timeline'));
  18. }
  19. public function local()
  20. {
  21. // TODO: Use redis for timelines
  22. $timeline = Status::whereHas('media')->whereNull('in_reply_to_id')->orderBy('id','desc')->simplePaginate(10);
  23. return view('timeline.public', compact('timeline'));
  24. }
  25. }