Closed nam-co closed 2 years ago
Hi,
First of all you must implement the last visited pages to store in your project. And the next will be load this last visited pages in to the spotlight constructor class.
I recommend to use Redis Connection for this functionality like this:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redis;
class LastSeen
{
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return $next($request);
}
$redis = Redis::connection();
$key = 'last_seen_' . Auth::id();
$value = (new \DateTime())->format("Y-m-d H:i:s");
$redis->set($key, $value);
return $next($request);
}
}
Function to get the last seen information:
public function lastSeen() {
$redis = Redis::connection();
return $redis->get('last_seen_' . $this->id);
}
You can then retrieve the last seen information on a user by calling the method as such:
$user->lastSeen();
I'm working on it and do PR I this next days.
Hi @PhiloNL , I got some ideas I hope you find them interesting
Thanks for the package