php - Update user table on login without touching vendors folder laravel 5.1

44

I want to update a database column which contains the last login every time a user logs in. Is there a way to do this without touching the vendors folder?

516

Answer

Solution:

Whenever user tries to login observe the auth.login event and update the user's last login time. Take a look at documentation

Event::listen('auth.login', function($user) {
    $user->last_login = new DateTime;

    $user->save();
});

People are also looking for solutions to the problem: php - Route pattern cannot reference variable name "trip_id" more than once

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.