A
A
albertshultz19002018-05-23 15:56:49
Laravel
albertshultz1900, 2018-05-23 15:56:49

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);
}
}

registered it in the Kernel:
\App\Http\Middleware\UserActivity::class,
After that, as necessary, I registered the method in the Users model:
public function isOnline()

{
    return Cache::has('user-is-online-' . $this->id);
}

When calling it in a blade template:
@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

Gives an error message
Class 'League\Flysystem\Cached\Storage\AbstractCache' not found.

I climbed inside the Cache class and found that it inherits from AbstractCache, but this abstract class is not in the project, what should I do, please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kuznetsov, 2018-05-23
@albertshultz1900

"use" used at the beginning of files where Cache was called???

K
Konstantin B., 2018-05-23
@Kostik_1993

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 question

Ask a Question

731 491 924 answers to any question