PHPackages                             divineomega/laravel-last-activity - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. divineomega/laravel-last-activity

Abandoned → [jord-jd/laravel-last-activity](/?search=jord-jd%2Flaravel-last-activity)Library[Authentication &amp; Authorization](/categories/authentication)

divineomega/laravel-last-activity
=================================

Stores the last activity time of users within your Laravel application

v2.0.0(2mo ago)157.9k4[3 PRs](https://github.com/Jord-JD/laravel-last-activity/pulls)LGPL-3.0-onlyPHPPHP &gt;=7.1CI failing

Since May 26Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/Jord-JD/laravel-last-activity)[ Packagist](https://packagist.org/packages/divineomega/laravel-last-activity)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-laravel-last-activity/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Laravel Last Activity
=====================

[](#laravel-last-activity)

Stores the last activity time of users within your Laravel application

Installation
------------

[](#installation)

To install the Laravel Last Activity package, just run the following Composer command from the root of your project.

```
composer require jord-jd/laravel-last-activity
```

Setup
-----

[](#setup)

This package requires you to register middleware within your `app\Http\Kernel.php` file. You will need add the middleware to every middleware group you wish to monitor activity for, as shown below.

```
protected $middlewareGroups = [
        'web' => [
            /* ... other web middleware ... */
            \JordJD\LaravelLastActivity\Http\Middleware\LastActivity::class
        ],

        'api' => [
            /* ... other api middleware ... */
            \JordJD\LaravelLastActivity\Http\Middleware\LastActivity::class
        ],
    ];
```

You also need to add the config file and migration to your project. To do so, simply run the following Artisan command.

```
php artisan vendor:publish --provider="JordJD\LaravelLastActivity\ServiceProvider"
```

You can then run the provided migration to add a `last_activity` field to your `users` table.

```
php artisan migrate
```

That's it. The `last_activity` field within your `users` will be automatically updated whenever the user interacts with your application via the web or API.

Alternative field name
----------------------

[](#alternative-field-name)

If you do not wish to use `last_activity` as the field name, this can be changed in the provided migration. You will also need to alter the configuration file

The published configuration file for this package can be found at `config/last-activity.php`.

```
