Last change
on this file since ec7b69d was 24a616f, checked in by Berat Kjufliju <kufliju@…>, 3 years ago |
added documents crud, added last_seen_to_user, edited views
|
-
Property mode
set to
100644
|
File size:
707 bytes
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Middleware;
|
---|
4 |
|
---|
5 | use App\Models\User;
|
---|
6 | use Closure;
|
---|
7 | use Auth;
|
---|
8 | use Cache;
|
---|
9 | use Carbon\Carbon;
|
---|
10 |
|
---|
11 | class LastSeenUserActivity
|
---|
12 | {
|
---|
13 | /**
|
---|
14 | * Handle an incoming request.
|
---|
15 | *
|
---|
16 | * @param \Illuminate\Http\Request $request
|
---|
17 | * @param \Closure $next
|
---|
18 | * @return mixed
|
---|
19 | */
|
---|
20 | public function handle($request, Closure $next)
|
---|
21 | {
|
---|
22 | if (Auth::check()) {
|
---|
23 | $expireTime = Carbon::now()->addMinute(1); // keep online for 1 min
|
---|
24 | Cache::put('is_online'.Auth::user()->id, true, $expireTime);
|
---|
25 |
|
---|
26 | //Last Seen
|
---|
27 | User::where('id', Auth::user()->id)->update(['last_seen' => Carbon::now()]);
|
---|
28 | }
|
---|
29 | return $next($request);
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.