xetaio/xetaravel-iptraceable

A simple package that update an IP field when the user login into the application.

11.0.0 2024-06-18 08:34 UTC

This package is auto-updated.

Last update: 2024-10-18 09:19:38 UTC


README

Xetaravel IpTraceable

A simple package that update an IP field when the user login into the application. Also work with the remember_me token.

Requirement

PHP

Installation

composer require xetaio/xetaravel-iptraceable

ServiceProviders

Import the IpTraceableServiceProvider in your config/app.php:

'providers' => [
  //...
  Xetaio\IpTraceable\Providers\IpTraceableServiceProvider::class,
  //...
]

Middleware

Import the IpTraceable middleware in your app/Http/Kernel.php in the web part:

protected $middlewareGroups = [
   'web' => [
       //...
       \Illuminate\Session\Middleware\StartSession::class,
       \Xetaio\IpTraceable\Http\Middleware\IpTraceable::class,
       //...
   ],
   //...
];

Note : It's very important to import the middleware after the Illuminate\Session\Middleware\StartSession middleware, since this package use the session.

Config file

Publish the package config file to your application :

php artisan vendor:publish --provider="Xetaio\IpTraceable\Providers\IpTraceableServiceProvider" --tag=config

Database

Create 2 fields last_login_ip and last_login_date (optional) in your database :

// Must be nullable
$table->ipAddress('last_login_ip')->nullable();
$table->dateTime('last_login_date')->nullable(); // (optional) Disabled by default

The fields name can be changed in the configuration file.

Contribute

If you want to contribute to the project by adding new features or just fix a bug, feel free to do a PR.