tusharthe/online-users-laravel
最新稳定版本:1.0
Composer 安装命令:
composer require tusharthe/online-users-laravel
包简介
Show the users online in your Laravel application
README 文档
README
Show the users online in your Laravel application
Instalation
install directly via composer
composer require tusharthe/online-users-laravel
After composer command, register service prodiver in app/config/app.php under providers:
tusharthe\OnlineUsers\OnlineUsersServiceProvider::class,
After this, add new middleware in app/Http/Kernel.php :
\tusharthe\OnlineUsers\Middleware\UsersOnline::class,
After this, add the Library (trait) in your model User in app/User.php:
class User extends Authenticatable { use \tusharthe\OnlineUsers\Library\OnlineUsers; ... }
After this, add the event in your EventServiceProvider in app/Providers/EventServiceProvider.php
under 'protected $listen = ' :
NOTE: in laravel 5.5 or above aumatically register event
'Illuminate\Auth\Events\Logout' => [ 'tusharthe\OnlineUsers\Listeners\LogoutListener', ],
Finally run :
php artisan vendor:publish for add the namespaces & select appropriate Provider tusharthe\OnlineUsers\OnlineUsersServiceProvider.
How To Use:
To get all Online Users just use the method allOnline() Like below:
$user = new User; $user->allOnline();
Or if you want to check if a specific user is online or not use the method isOnline():
$user = User::find($id); $user->isOnline();
You Can also able to to set timming of user in app/config/OnlineUser.php
Default 3 min is set.
Laravel compatibility
5.4 or above
统计信息
- 总下载量: 2.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-25