samedi 28 septembre 2019

How can I get the value of this variable?

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('/');
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2oaQxvL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire