Skip to content

Stores the last activity time of users within your Laravel application

License

Notifications You must be signed in to change notification settings

jeremyallebe/laravel-last-activity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Last Activity

Stores the last activity time of users within your Laravel application

Installation

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

composer require divineomega/laravel-last-activity

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 ... */
            \DivineOmega\LaravelLastActivity\Http\Middleware\LastActivity::class
        ],

        'api' => [
            /* ... other api middleware ... */
            \DivineOmega\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="DivineOmega\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

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.

<?php

return [
    
    // Field in which the last activity date time will be stored.
    'field' => 'last_activity',
    
];

About

Stores the last activity time of users within your Laravel application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%