From 593d53223606d1795a1b8ecf4e3ce7652c4d39b1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 17 Jul 2018 18:06:57 -0600 Subject: [PATCH] Update AccountController --- app/Http/Controllers/AccountController.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 1df96265f..3ef8ef272 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -18,15 +18,24 @@ class AccountController extends Controller public function notifications(Request $request) { $this->validate($request, [ - 'page' => 'nullable|min:1|max:3' + 'page' => 'nullable|min:1|max:3', + 'a' => 'nullable|alpha_dash', ]); $profile = Auth::user()->profile; + $action = $request->input('a'); $timeago = Carbon::now()->subMonths(6); - $notifications = Notification::whereProfileId($profile->id) - ->whereDate('created_at', '>', $timeago) - ->orderBy('id','desc') - ->take(30) - ->simplePaginate(); + if($action && in_array($action, ['comment', 'follow', 'mention'])) { + $notifications = Notification::whereProfileId($profile->id) + ->whereAction($action) + ->whereDate('created_at', '>', $timeago) + ->orderBy('id','desc') + ->simplePaginate(30); + } else { + $notifications = Notification::whereProfileId($profile->id) + ->whereDate('created_at', '>', $timeago) + ->orderBy('id','desc') + ->simplePaginate(30); + } return view('account.activity', compact('profile', 'notifications')); } @@ -105,4 +114,5 @@ class AccountController extends Controller } return $notifications; } + }