I have a laravel 5.2 app with authentication.I have built a custom global middleware that updates a "last_seen" column on the users table for each user.
Note: It is a middleware that runs after the request.
I use the "UTC" timezone so that there would be no errors when calculating the difference anywhere in the world.
Everything works fine and as expected,until i log out.When I log out,the column is updated with the time in my current timezone "romania". I have no idea why that is,since I never declared a timezone other than "UTC".
Here is my middleware code:
<?php
namespace App\Http\Middleware;
use Auth;
use Closure;
use Carbon\Carbon;
class LastSeenMiddleware
{
public function handle($request, Closure $next)
{
$response = $next($request);
if(Auth::check()){
Auth::user()->last_seen = Carbon::now();
Auth::user()->save();
}
return $response;
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire