Im following a tutorial on adding a last visited feature to my app from here
https://medium.com/@grmcameron/implementing-last-visited-last-seen-in-laravel-237dbbed9027
Basically, add a middleware, add it to the $middlewareGroups in Kernel.php, add a datetime column
$table->dateTime('last_online')->nullable();
The middleware is as follows;
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Auth;
use Closure;
class LastOnline
{
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return $next($request);
}
$user = Auth::user();
$user->update([
'last_online' => new \DateTime(),
]);
return $next($request);
}
}
But for some reason, the column doesnt upload on each request.
If i dd($user)
it returns the correct user, but no update at all and also no errors are generated.
Just nothing.
Any help would be greatly appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire