定制 lopatin96/laravel-user-online 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lopatin96/laravel-user-online

最新稳定版本:1.0.1

Composer 安装命令:

composer require lopatin96/laravel-user-online

包简介

Laravel user online

README 文档

README

Migrations

Run migrations to create the necessary tables.

php artisan migrate

Middleware

Add LastUserActivity middleware to middleware array in app/Http/Kernel.php:

protected $middlewareGroups = [
    
    \Atin\LaravelUserOnline\Http\Middleware\LastUserActivity::class,
];

Trait

You cant optionally add HasOnline trait to User model to get the online status of the user.

use Atin\LaravelUserOnline\Traits\HasOnline;

class User extends Authenticatable
{
    use HasOnline, …

don't forget to cast last_seen_at property to datetime in your User model:

protected $casts = [
    …
    'last_seen_at' => 'datetime',
];

and then you can check the online status:

auth->user()->isOnline();

Publishing

Migrations

php artisan vendor:publish --tag="laravel-user-online-migrations"

Config

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

统计信息

  • 总下载量: 7.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-20