<commit_before><?php

namespace App\Listeners;

use Carbon\Carbon;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Logout;

class UserEventListener
{
    /**
     * Handle user login events.
     */
    public function onUserLogin(Login $login)
    {
        $login->user->last_ip = request()->ip();
        $login->user->last_login_at = Carbon::now();
        $login->user->save();

        logger()->info("User logged in: UserId:{$login->user->id}");
    }

    /**
     * Handle user logout events.
     */
    public function onUserLogout(Logout $logout)
    {
        logger()->info('User logged out');
    }

    /**
     * Register the listeners for the subscriber.
     *
     * @param Illuminate\Events\Dispatcher $events
     */
    public function subscribe($events)
    {
        $events->listen(
            'Illuminate\Auth\Events\Login',
            'App\Listeners\UserEventListener@onUserLogin'
        );

        $events->listen(
            'Illuminate\Auth\Events\Logout',
            'App\Listeners\UserEventListener@onUserLogout'
        );
    }
}<commit_msg>Small refactor<commit_after><?php

namespace App\Listeners;

use App\Models\User;
use Carbon\Carbon;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Logout;

class UserEventListener
{
    /**
     * Handle user login events.
     */
    public function onUserLogin(Login $login)
    {
        $this->touchAudit($login->user);

        logger()->info("User logged in: UserId:{$login->user->id}");
    }

    /**
     * Handle user logout events.
     */
    public function onUserLogout(Logout $logout)
    {
        logger()->info('User logged out');
    }

    /**
     * Register the listeners for the subscriber.
     *
     * @param Illuminate\Events\Dispatcher $events
     */
    public function subscribe($events)
    {
        $events->listen(
            'Illuminate\Auth\Events\Login',
            'App\Listeners\UserEventListener@onUserLogin'
        );

        $events->listen(
            'Illuminate\Auth\Events\Logout',
            'App\Listeners\UserEventListener@onUserLogout'
        );
    }

    protected function touchAudit(User $user)
    {
        $user->last_ip = request()->ip();
        $user->last_login_at = Carbon::now();
        $user->save();
    }
}
{'fraction_non_alphanumeric': 0.13924050632911392, 'fraction_numerical': 0.0, 'mean_word_length': 2.251063829787234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7230217', 'n_tokens_mistral': 677, 'n_tokens_neox': 684, 'n_words': 122}