LaravelPackages.net
Acme Inc.
Toggle sidebar
fomvasss/laravel-last-visit

Check last visit user

15
2
1.0.0
About fomvasss/laravel-last-visit

fomvasss/laravel-last-visit is a Laravel package for check last visit user. It currently has 2 GitHub stars and 15 downloads on Packagist (latest version 1.0.0). Install it with composer require fomvasss/laravel-last-visit. Discover more Laravel packages by fomvasss or browse all Laravel packages to compare alternatives.

Last updated

Laravel last visit

A package for fixing the last visit of an authorized user in the system

Installation

Require this package with composer

composer require fomvasss/laravel-last-visit

Publish package config (if need)

php artisan vendor:publish --provider="Fomvasss\LastVisit\ServiceProvider"

Add middleware to Http/Kernel.php, for example in web group:

    protected $middlewareGroups = [
        'web' => [
            //...
            \Fomvasss\LastVisit\Middleware\LogLastVisitMiddleware::class,
        ],
    ];

Usage

  • Add in your User model next trait: Visitable (Fomvasss\LastVisit\Traits)

  • Use method isOnline()

Example:

$users = User::select('id')->get();
foreach ($user as $user) {
    if ($user->isOnline()) {
        $user->last_visit = \Carbon\Carbon::now();
        $user->save();
    }
}

This code you can use in CRON schedule.

Star History Chart