From 51f8fe5bdea2358959b6d6e624454cdb6e612a67 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 14 Jan 2021 18:51:19 -0700 Subject: [PATCH] Update ApiV1Controller --- app/Http/Controllers/Api/ApiV1Controller.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 2ecd3ed0..96c37b04 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1435,13 +1435,15 @@ class ApiV1Controller extends Controller $limit = $request->input('limit') ?? 3; $user = $request->user(); - $key = 'user:last_active_at:id:'.$user->id; - $ttl = now()->addMinutes(5); - Cache::remember($key, $ttl, function() use($user) { - $user->last_active_at = now(); - $user->save(); - return; - }); + if($user) { + $key = 'user:last_active_at:id:'.$user->id; + $ttl = now()->addMinutes(5); + Cache::remember($key, $ttl, function() use($user) { + $user->last_active_at = now(); + $user->save(); + return; + }); + } if($min || $max) { $dir = $min ? '>' : '<';