source: app/Http/Middleware/LastSeenUserActivity.php

Last change on this file 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
RevLine 
[24a616f]1<?php
2
3namespace App\Http\Middleware;
4
5use App\Models\User;
6use Closure;
7use Auth;
8use Cache;
9use Carbon\Carbon;
10
11class 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.