fomvasss / laravel-last-visit
Check last visit user
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:composer-package
Requires
- php: >=7.0.0
- illuminate/support: 5.6.*|5.7.*
This package is auto-updated.
Last update: 2020-08-14 20:49:03 UTC
README
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.