acelords / laravel-users-online
This package will provide an online users management.
3.0.6
2023-02-01 14:31 UTC
Requires (Dev)
- codacy/coverage: dev-master
- illuminate/auth: >=8.0
- illuminate/cache: >=8.0
- illuminate/database: >=8.0
- illuminate/session: >=8.0
- illuminate/support: >=8.0
- orchestra/testbench: >=6.0
- phpunit/phpunit: >=8
This package is auto-updated.
Last update: 2024-10-29 18:04:15 UTC
README
Laravel compatibility
Installation
Add the new required package in your composer.json
"acelords/laravel-users-online": "^3.0"
Run composer update
or php composer.phar update
.
Or install directly via composer
composer require acelords/laravel-users-online
After composer command, add the trait in your model User in app/User.php
:
class User extends Authenticatable { use \HighIdeas\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();
Installation and usage on last versions of framework: