lopatin96 / laravel-user-online
Laravel user online
Installs: 7 096
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.0
This package is auto-updated.
Last update: 2024-11-29 17:10:57 UTC
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"