Looking to hire Laravel developers? Try LaraJobs

laravel-user-online maintained by lopatin96

Description
Laravel user online
Last update
2024/02/29 16:44 (dev-master)
License
Links
Downloads
7 855

Comments
comments powered by Disqus

Install

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"