aerojun's avatar

Cache Dependency Injection issue

I'm trying to use dependency injection in my class like this:

<?php

namespace App\Http\Controllers\Product;

use Illuminate\Database\DatabaseManager as DB;
use Illuminate\Cache\Repository as Cache;
use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

class InventarioController extends Controller
{
    protected $cache;

    public function __construct(Cache $cache)
    {
        $this->cache = $cache;
    }
}

But i get this error:

Argument 1 passed to App\Http\Controllers\Producto\InventarioController::__construct() must be an instance of Illuminate\Cache\Repository, instance of Illuminate\Cache\CacheManager given

I have added the alias to config/app.php like this:

$app->alias('cache', 'Illuminate\Cache\Repository');

Any idea why it throws me that error?

0 likes
1 reply

Please or to participate in this conversation.