Logout event Listener return null user data

Posted 5 days ago by AdhamLap

hello,

i make listener on Logout for update user status in users table this my code.

provider

        'Illuminate\Auth\Events\Logout' => [
            'App\Listeners\LogSuccessfulLogout',
        ],

LogSuccessfulLogout


class LogSuccessfulLogout implements ShouldQueue
{
    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    
    public function handle(Logout $event)
    { 
        dd($event); // return null

        $this->user->update([
            'status' => 0
        ]);
    }
}

also i try

public function __construct(Request $request, User $user)
    {
        $this->request = $request;
        $this->user = $user;
    }

    /**
     * Handle the event.
     *
     * @param Logout $event
     * @return void
     */
    public function handle(Logout $event)
    {
        dd($this->user); // return empty #attributes: []
       

//        dd($event->user);
        $this->user->update([
            'status' => 0
        ]);
    }

how i can get user data before logout

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.