Reputation: 235
i'm tring laravel Modules and Repository.I had created Repository in App and Controller in module. But when controller call Repository it report "ReflectionException Class Modules\Product\Http\Controllers\ProductEntryRepository does not exist".
But ProductEntryRepository in App\Reppsitory but it error in Controlller.
namespace Modules\Product\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use \App\Repositories\ProductCategoryRepository;
use \App\Repositories\ProductCategoryEntryRepository;
class ProductCategoryController extends Controller
{
/**
* @var PostRepository
*/
protected $request;
protected $product_category;
protected $product_category_entry;
public function __construct(Request $request, ProductCategoryRepository $product_category, ProductEntryRepository $product_category_entry){
$this->request = $request;
$this->product_category = $product_category;
$this->product_category_entry = $product_category_entry;
}
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
return view('product::index');
}
Upvotes: 2
Views: 3670
Reputation: 11083
You should just add use \App\Repositories\ProductEntryRepository;
at the top of your controller :)
namespace Modules\Product\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use \App\Repositories\ProductCategoryRepository;
use \App\Repositories\ProductCategoryEntryRepository;
use \App\Repositories\ProductEntryRepository;
class ProductCategoryController extends Controller
{
//......
}
Or i think you mean ProductCategoryEntryRepository
not ProductEntryRepository
in the construct !!
public function __construct(Request $request, ProductCategoryRepository $product_category, ProductCategoryEntryRepository $product_category_entry){
$this->request = $request;
$this->product_category = $product_category;
$this->product_category_entry = $product_category_entry;
}
Upvotes: 2