0
My application is returning an error while storing the cache, I saw it was saving, but it is returning this error. Can anyone tell me why? Here is my function and error:
function that returns error:
<?php
namespace App\Repositories\ProductFilter;
use App\Models\Product;
use App\Repositories\Contracts\IProductFilterRepository;
use Illuminate\Support\Facades\Cache;
class ProductFilterRepository implements IProductFilterRepository
{
public function getProductsRecommendations($keywords)
{
$expiration = 10;
$keyName = 'productsRecommended';
return Cache::remember($keyName, $expiration, function ($keywords) {
return Product::query()->where(function ($productsAll) use ($keywords) {
if ($keywords) {
foreach ($keywords as $keyword)
$productsAll->orWhere('title', 'LIKE', '%' . $keyword . '%')->orWhere('description', 'LIKE', '%' . $keyword . '%')->orWhere('code', 'LIKE', '%' . $keyword . '%');
}
})->where('status', 'active')->get();
});
}
}
error:
ArgumentCountError
Too few arguments to function App\Repositories\ProductFilter\ProductFilterRepository::App\Repositories\ProductFilter\{closure}(), 0 passed in /var/www/vendor/laravel/framework/src/Illuminate/Cache/Repository.php on line 385 and exactly 1 expected
http://localhost:8888/recommended
My . env with cache settings:
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
REDIS_URL=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=redis
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT = redis
Does anyone know what it can be?
error due to lack of arguments, there is no way to know only with what you put, it is a local development error
– novic
@novic put more information in my question. Look if you know, please.
– Mecaloop
Seems to be the
namespace
take a look at where you use this because it seems there to be the problem!– novic
@novic if you are interested I posted an answer with what was going wrong in my role. I thank you for the willingness to try to help me. Thank you very much. Beyoncé bless you.
– Mecaloop