From a7b186d7fb348c361e392b64bf5345dd703beccc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 31 May 2018 16:05:39 -0600 Subject: [PATCH] Add local timeline to TimelineController --- app/Http/Controllers/TimelineController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 6564f17b..924dba6d 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -3,7 +3,8 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; -use App\{Status, User}; +use Auth; +use App\{Follower, Status, User}; class TimelineController extends Controller { @@ -14,7 +15,17 @@ class TimelineController extends Controller public function personal() { - $timeline = Status::orderBy('id','desc')->paginate(10); + // TODO: Use redis for timelines + $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id'); + $timeline = Status::whereHas('media')->whereNull('in_reply_to_id')->whereIn('profile_id', $following)->orderBy('id','desc')->simplePaginate(10); return view('timeline.personal', compact('timeline')); } + + public function local() + { + // TODO: Use redis for timelines + $timeline = Status::whereHas('media')->whereNull('in_reply_to_id')->orderBy('id','desc')->simplePaginate(10); + return view('timeline.public', compact('timeline')); + } + }