In logout function, I need to get the value of $time. This variable was declared in other function, when user logged in.
Broadcast::channel('chat', function ($user) {
$ip = Request::ip();
$time = now();
if (auth()->check() && !session()->has('name')) {
UserInfo::storeUser();
session()->put('name',$user->name);
return [
'id' => $user->id,
'ip' => $ip,
'name' => $user->name,
'joined' => $time,
];
}
});
When user logged out, I have to check his 'id' and value of 'joined'. How can I do this?
public function logout() {
$id = auth()->id();
$info = \App\UserInfo::where('id', $id)
-> where('joined', $time)
->update(['left' => now()]);
auth()->logout();
session()->forget('name');
session()->put('left',now());
return redirect('/');
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire