PHPackages                             brianclogan/laravel-user-status - 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. brianclogan/laravel-user-status

ActiveLibrary

brianclogan/laravel-user-status
===============================

Track user status automatically, or have custom statuses set.

01[1 issues](https://github.com/brianclogan/laravel-user-status/issues)[4 PRs](https://github.com/brianclogan/laravel-user-status/pulls)PHPCI passing

Since May 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/brianclogan/laravel-user-status)[ Packagist](https://packagist.org/packages/brianclogan/laravel-user-status)[ RSS](/packages/brianclogan-laravel-user-status/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (0)

Laravel User Status
===================

[](#laravel-user-status)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7553df1bfe7bbed50c91a27920f7c37b55158ae74dd9fb8ba733f21cf2f3d332/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627269616e636c6f67616e2f6c61726176656c2d757365722d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brianclogan/laravel-user-status)[![GitHub Tests Action Status](https://camo.githubusercontent.com/9de38bb57a23d415d88ddfa9d9fcb75a931281203347a78511b8eebcef63e840/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f627269616e636c6f67616e2f6c61726176656c2d757365722d7374617475732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/brianclogan/laravel-user-status/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/7738209a8364da4dabe2f0c82f90497a8e24b488a7dcf5ade9b94c458066ea27/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f627269616e636c6f67616e2f6c61726176656c2d757365722d7374617475732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/brianclogan/laravel-user-status/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/43ce507b594a1d34c0f05525d7e9e87f278fdad1d8a4e98dba7e90c2eb535665/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627269616e636c6f67616e2f6c61726176656c2d757365722d7374617475732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brianclogan/laravel-user-status)

Track user status automatically, or have custom statuses set by the user.

Originally, this package was going to be for users, but I realized that it could be used for any model that you want to track the status of (ie: Teams).

So, while it's called Laravel User Status, it can be used for any model that you want to track the status of.

Features
--------

[](#features)

- Automatically track user status
- Custom statuses
- Real-time status updates
- Keep history of statuses
- Customizable
- Laravel Echo support

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

[](#installation)

You can install the package via composer:

```
composer require brianclogan/laravel-user-status
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-user-status-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-user-status-config"
```

This is the contents of the published config file:

```
return [

    /**
     * Tables
     *
     * The table names used by the package.
     */
    'tables' => [
        'status_table' => env('USER_STATUS_TABLE', 'user_statuses'),
    ],

    /**
     * Laravel Echo Configuration
     *
     * This is used to broadcast the status changes to the frontend
     * and update the status in real-time. (if enabled)
     */
    'echo' => [
        /**
         * Enable or disable the broadcasting of the status changes
         */
        'enabled' => env('USER_STATUS_ECHO_ENABLED', false),
        'channel' => 'statusable.{type}.{id}',
        /**
         * Enable or disable the broadcasting of the presence changes
         */
        'presences_enabled' => env('USER_STATUS_PRESENCES_ENABLED', false),
        'presences' => 'statusable.{type}.{id}.presences',
    ],

    /**
     * Middleware
     *
     * This is applied when a user makes a request. It will update the user's status
     * based on the configuration below.
     *
     * If you want to disable this, set `enabled` to false.
     *
     * If you want to apply this to a different group, you can add more groups to the `groups` array.
     * If you apply `api`, it will set the user status online for any API request which is not recommended.
     *
     * Feel free to disable this, and make your own middleware if you want.
     */
    'middleware' => [
        'enabled' => env('USER_STATUS_MIDDLEWARE_ENABLED', true),
        'groups' => [
            'web',
        ],
        'status' => 'online',
        'reason' => 'active',
        'meta' => null,
    ],

    /**
     * Status Model
     *
     * The model used to store the statuses, you can extend the model
     * and change the class here. NOT RECOMMENDED, but possible.
     */
    'status_model' => \BrianLogan\LaravelUserStatus\Models\Status::class,

    /**
     * Keep History
     *
     * If enabled, the package will keep past statuses in the database.
     *
     * This is useful for analytics and other purposes, but is disabled
     * by default to reduce the size of the database.
     *
     * If you enable this, you should also enable the `echo.enabled` option
     * to keep the frontend in sync with the backend.
     *
     * This will update the status model to use a morphMany relationship
     * instead of a morphOne relationship.
     */
    'keep_history' => env('USER_STATUS_KEEP_HISTORY', false),

];
```

Usage
-----

[](#usage)

Add the `HasStatus` trait to the model you want to track the status of.

```
use BrianLogan\LaravelUserStatus\Traits\HasStatus;

class User extends Model
{
    use HasStatus;
}
```

### Get the latest status

[](#get-the-latest-status)

```
$user = User::find(1);
$user->getLatestStatus();
```

### Set a status

[](#set-a-status)

When calling `setStatus`, only the `status` is required. The `reason` and `meta` are optional.

`meta` can be used to store additional information about the status, such as colors, icons, custom messages, etc.

```
$user = User::find(1);
$user->setStatus(status: 'active', reason: 'User is active', meta: ['foo' => 'bar']);
```

> *NOTE:* If you have `keep_history` enabled, rather than updating the status, it will create a new record.

Scopes
------

[](#scopes)

### Get all with a specific status

[](#get-all-with-a-specific-status)

```
User::whereStatus('active')->get();
```

> *NOTE:* If you have `keep_history` enabled, it will return all records with the status, not just the latest.

### Get all with a specific status reason

[](#get-all-with-a-specific-status-reason)

```
User::whereStatusReason('User is active')->get();
```

> *NOTE:* If you have `keep_history` enabled, it will return all records with the status, not just the latest.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Brian Logan](https://github.com/brianclogan)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance60

Regular maintenance activity

Popularity1

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 73.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/093f0f4c952fb410a2324eb9acfa28d8a9bd44ed9158bce0b336fec77a674820?d=identicon)[brianclogan](/maintainers/brianclogan)

---

Top Contributors

[![brianclogan](https://avatars.githubusercontent.com/u/9066551?v=4)](https://github.com/brianclogan "brianclogan (38 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")

---

Tags

laravelonline-statususer-statususer-statuses

### Embed Badge

![Health badge](/badges/brianclogan-laravel-user-status/health.svg)

```
[![Health](https://phpackages.com/badges/brianclogan-laravel-user-status/health.svg)](https://phpackages.com/packages/brianclogan-laravel-user-status)
```

PHPackages © 2026

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