I'm using Laravel-8 to develop my project, and I have a resource controller named ProductController
which is placed at Admin
directory inside Controllers
, just like this image is showing:
Then at my route file, I coded this:
Route::resource('products', 'ProductController');
Route::resource('permissions', 'PermissionController');
But when I want to go to products
route, I get this message:
IlluminateContractsContainerBindingResolutionException Target class
[AppHttpControllersAdminProductController] does not exist.
Now you may say in Laravel-8, I have to use Route::get('/', ProductController::class);
, but as you can see above, I have also determined a permissions
route to PermissionController
by the old method and it is working completely fine!
The namespace of Admin is also specified at RouteServiceProvider
:
Route::middleware(['web' , 'auth' , 'auth.admin'])
->namespace('AppHttpControllersAdmin')
->prefix('admin')
->group(base_path('routes/web/admin.php'));
Note that I also tried Route::resource('products', ProductController::class);
, but still get the same error.
I guess the issue is coming from another part!
So if you have any idea about this, please let me know, I would really appreciate any idea or suggestion from you guys...
Thanks in advance.
UPDATE #1:
ProductController
goes like this:
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpControllersController;
use AppModelsProduct;
question from:
https://stackoverflow.com/questions/65856338/laravel-8-target-class-productcontroller-does-not-exist 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…