Download the PHP package zaichaopan/online-status without Composer
On this page you can find all versions of the php package zaichaopan/online-status. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zaichaopan/online-status
More information about zaichaopan/online-status
Files in zaichaopan/online-status
Package online-status
Short Description A package to show user online status in your laravel app
License MIT
Informations about the package online-status
Online Status
This packages adds functionality to show user online status, online users and online user number in your laravel app. This package can be used in laravel 5.5 or higher.
Installation
This packages uses redis behind the screen. So please install redis in your machine in order to use package.
Usage
-
Add HasOnlineStatus trait to your user model
- Set online expiration time.
This package uses lifetime in config/session.php as the default user online expiration time. If user remains inactive during this time period, he or she will be considered offline. So if you want to customize. you can override it in config/session.php or you can override it in User model as follow
- Apply UserOnline Middleware.php
Now when authenticated user makes a web request, his or her online status will be automatically be set.
Available Apis
-
Get whether user is online:
-
Get total online user number
-
Get online users
- Set user online
As long as you apply the UserOnline middleware properly, it will automatically set and update authenticated user online status. In case you want to set it manually, you can use online method provided by the trait.
- Set user offline
This package listens for Logout event. When user logs out, it will set user online status as offline. In case you may want to set user offline manually, you can use offline method provided by the trait.
Events
This packages raises two events during the updating user online status process. You may attach listeners to these two events in your EventServiceProvider:
The Online event will only fire once. It won't fire again if the user is already online