PHPackages                             happydemon/usrlastly - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. happydemon/usrlastly

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

happydemon/usrlastly
====================

Keep track of your users' last visit

0.2(11y ago)142204[2 issues](https://github.com/happyDemon/UsrLastly/issues)MITPHPPHP &gt;=5.4.0

Since Mar 29Pushed 10y ago3 watchersCompare

[ Source](https://github.com/happyDemon/UsrLastly)[ Packagist](https://packagist.org/packages/happydemon/usrlastly)[ Docs](http://github.com/happydemon/usrlastly)[ RSS](/packages/happydemon-usrlastly/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

UsrLastly
=========

[](#usrlastly)

This nifty little package makes it easy to store and retrieve a user's 'last seen' status.

It's a light implementation that's easy to extend.

It uses a middleware to check if a user is logged in, if so it will store the user's current visit.

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

[](#installation)

First add the package to your composer file by runningthis command:

```
composer require happydemon/usrlastly

```

This will install the latest version.

Next add the service provider in your app.php config:

```
    'providers' => [
        ...
        'HappyDemon\UsrLastly\UsrLastlyServiceProvider',
    ]
```

Next publish the config file:

```
php artisan vendor:publish

```

Now it's time to register `LastSeenMiddleware` as global middleware in `app/Http/Kernel.php`:

```
	protected $middleware = [
		...
		'HappyDemon\UsrLastly\Middleware\LastSeenMiddleware'
	];
```

Lastly let's move on to your user model, open it and add the required trait:

Above your class reference the trait

```
use HappyDemon\UsrLastly\LastSeenTrait as LastSeen;
```

and in your user model add

```
use LastSeen;
```

Storages
--------

[](#storages)

I've bundled 2 types of storage, this is where the 'last seen status' gets stored.

You can either store this status in your database or with Redis.

### Database

[](#database)

To let this package do its work you'll first need to publish and run a database migration

```
php artisan vendor:publish --provider="HappyDemon\UsrLastly\UsrLastlyServiceProvider" --tag="migrations"
php artisan migrate
```

That should have prepared your database and you should be ready.

### Redis

[](#redis)

This storage requires even less setup, all you have to do is open up `config/userlastly.php` and change the `storage` key to `redis`

User provider
-------------

[](#user-provider)

I'm sure not everybody is using Laravel's built-in Auth to handle user authentication so I've extracted this bit too, at this moment though it's the only auth implemented.

This is something that's used by the package, not something other developers should worry about.

We can do this in 3 steps:

- Create a class that implements `HappyDemon\UsrLastly\User` with a `getUser()` method that returns a logged in user or false
- Binding that class to laravel's container
- Change `config/userlastly.php`'s `user_provider` key to name of that binding.

You can check the docs for the worked out example.

Retrieving 'last seen' status
-----------------------------

[](#retrieving-last-seen-status)

Load your user like you would normally and call `lastSeen()`, as an example I'll just grab the first user in the database:

```
$user = User::find(1);

dd($user->lastSeen());
```

That method should return an object with 2 properties:

- *date* which is a `Carbon` date object
- *request*, an array which holds information on where the user was

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

4085d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/91a724ec7e90c57050c6fa0fa34f9faeec7041896866d4f8ddc85ed00b0f8887?d=identicon)[happyDemon](/maintainers/happyDemon)

---

Top Contributors

[![happyDemon](https://avatars.githubusercontent.com/u/38573?v=4)](https://github.com/happyDemon "happyDemon (7 commits)")[![marijang](https://avatars.githubusercontent.com/u/1381443?v=4)](https://github.com/marijang "marijang (6 commits)")

---

Tags

laraveluserlastUsrlastlyseen

### Embed Badge

![Health badge](/badges/happydemon-usrlastly/health.svg)

```
[![Health](https://phpackages.com/badges/happydemon-usrlastly/health.svg)](https://phpackages.com/packages/happydemon-usrlastly)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[firefly-iii/data-importer

Firefly III Data Import Tool.

7905.8k](/packages/firefly-iii-data-importer)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

98145.2k3](/packages/nickurt-laravel-akismet)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

987.7k2](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
