Answer the question
In order to leave comments, you need to log in
When calling return Cache::has('user-is-online-'. $this->id); Gives error Class 'League\Flysystem\Cached\Storage\AbstractCache' not found?
Hello! I rummaged through the entire Internet, I can’t find a solution to this problem. I have a project on laravel 5.6 NGINX server, I want to make it visible when the user is online, when offline, naturally. Created a middleware called UserActivity :
class UserActivity {
public function handle($request, Closure $next)
{
if(Auth::check()) {
$expiresAt = Carbon::now()->addMinutes(5);
Cache::put('user-is-online-' . Auth::user()->id, true, $expiresAt);
}
return $next($request);
}
}
\App\Http\Middleware\UserActivity::class,
public function isOnline()
{
return Cache::has('user-is-online-' . $this->id);
}
@foreach($users as $item)
@if($item->isOnline())
<li class="media"><img class="media-object" src="../assets/img/prof/prof3.jpg" width="35" height="35" alt="...">
<i class="online dot"></i>
<div class="media-body">
<h5 class="media-heading">{{ $item->name }}</h5>
<div class="media-heading-sub"></div>
</div>
</li>
@endif
@endforeach
Class 'League\Flysystem\Cached\Storage\AbstractCache' not found.
Answer the question
In order to leave comments, you need to log in
"use" used at the beginning of files where Cache was called???
Try changing the driver to Redis, update composer.
This construction is incorrect, here you need to pass the number of minutes, i.e. 1, 2, 5, 10 or any other number, and not the timestamp as you have
Replace with this, maybe even this is the problem$expiresAt = 5;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question