From 545efbeee3b82a64650a821e39088185ee0bca86 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 9 Jun 2018 17:30:54 -0600 Subject: [PATCH] Update AccountController, add pagination to notifications --- app/Http/Controllers/AccountController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 4a0b5bd5..6f5eeea4 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Carbon\Carbon; use Auth, Cache, Redis; use App\{Notification, Profile, User}; @@ -15,10 +16,17 @@ class AccountController extends Controller public function notifications(Request $request) { + $this->validate($request, [ + 'page' => 'nullable|min:1|max:3' + ]); $profile = Auth::user()->profile; - //$notifications = $this->fetchNotifications($profile->id); + $timeago = Carbon::now()->subMonths(6); $notifications = Notification::whereProfileId($profile->id) - ->orderBy('id','desc')->take(30)->simplePaginate(); + ->whereDate('created_at', '>', $timeago) + ->orderBy('id','desc') + ->take(30) + ->simplePaginate(); + return view('account.activity', compact('profile', 'notifications')); }