Today, We want to share with you Laravel check User online offline.In this post we will show you Laravel CHECK IF USER ONLINE OR AWAY SCRIPT, hear for Who is online Laravel script to display active Users at any moment we will give you demo and example for implement.In this post, we will learn about Laravel Check Member’s/ User’s Online or Offline Status with an example.
Laravel check User online offline
There are the Following The simple About Laravel check User online offline Full Information With Example and source code.
As I will cover this Post with live Working example to develop how to show live online user using Laravel with ajax jquery, so the how to check how many user online in Laravel for this example is following below.
Step:1 Create a fresh Laravel project
laravel new fbchat
Step:2 Setup MySQL database and migrate table
php artisan migrate
Step: 3 make a Laravel middleware
php artisan make:middleware CheckUserOnlineOffline
E-junkie: Sell digital downloads online
E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!
Also see:
App\Http\Middleware\CheckUserOnlineOffline .php
addMinutes(1); Cache::put('user-is-online-' . Auth::user()->id, true, $useroffAt); } return $next($request); } }
Step: 4 Add a class into Kernel
\App\Http\Middleware\CheckUserOnlineOffline::class,
Add $middlewareGroups
protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\CheckUserOnlineOffline::class, ], 'api' => [ 'throttle:60,1', 'bindings', ], ];
Step: 5 Include a simple function into the User http Model
public function isCheckOnlineOrNot() { return Cache::has('user-is-online-' . $this->id); }
Step: 6 Check current user Online or offline in Laravel Web application
@if($user->isCheckOnlineOrNot()) user is online!! @endif
how to check online users on website
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about Laravel check User online offline.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.