Skip to content

Instantly share code, notes, and snippets.

@georgewritescode
Created January 27, 2018 03:06
Show Gist options
  • Save georgewritescode/c2165f5eecd2e9932d9811c34370b4a8 to your computer and use it in GitHub Desktop.
Save georgewritescode/c2165f5eecd2e9932d9811c34370b4a8 to your computer and use it in GitHub Desktop.
database lastseen
<?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);
}
$user = Auth::user();
$user->update([
'last_seen' => new \DateTime(),
]);
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment