samuelterra22/laravel-users-online

This package will provide an online users management.

v0.0.1 2025-07-16 02:56 UTC

This package is auto-updated.

Last update: 2025-07-16 02:57:45 UTC


README

Latest Stable Version Total Downloads License Build Status Codacy Badge Codacy Badge

Installation

Add the new required package in your composer.json

"samuelterra22/laravel-users-online": "^1.0"

Run composer update or php composer.phar update.

Or install directly via composer

composer require samuelterra22/laravel-users-online

After composer command, add the trait in your model User in app/User.php:

class User extends Authenticatable
{
    use \SamuelTerra22\UsersOnline\Traits\UsersOnlineTrait;
...

Finally run php artisan vendor:publish for add the namespaces

Usage

For show the users online just use the method allOnline():

$user = new User;
$user->allOnline();

Or if you want to check if a specific user is online use the method isOnline():

$user = User::find($id);
$user->isOnline();

You can sort all users online with the methods mostRecentOnline() and leastRecentOnline():

$user = new User;
$user->mostRecentOnline();
$user->leastRecentOnline();

Using with Real-time Facades:

use Facades\App\User as UserFacade;

UserFacade::mostRecentOnline();
UserFacade::leastRecentOnline();