irius-digital/last-login-activity

Package to get last login activity

1.0.0 2022-04-10 18:15 UTC

README

Simple package to get and logged last login activity/activities

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Simple package where you can save user login activity (my first time to create a package) apologies.

Installation

You can install the package via composer:

composer require irius-digital/last-login-activity

You can publish and run the migrations with:

php artisan vendor:publish --tag="last-login-activity-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="last-login-activity-config"

This is the contents of the published config file:

return [
    'save_last_login' => [
        'enabled' => env('SAVE_LAST_LOGIN', true),
    ],
];

Usage

Add this to your EventServiceProvider.php

use Illuminate\Auth\Events\Login;
use IriusDigital\LastLoginActivity\Events\LastActivityEvent;


protected $listen = [
        Login::class => [
            LastActivityEvent::class,
        ],
    ];

Add to your user model

use IriusDigital\LastLoginActivity\Traits\LoginActivities;

class User extends Authenticatable
{
    ...
    use LoginActivities;
    

Then you can access your user model with

    $user->latestLoggedIp
    
    $user->loginActivities

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.