I have a problem with the Route::resource()
method in Laravel 8.x.
The error it returns is:
Target class [Admin\App\Http\Controllers\Admin\ProfileController] does not exist.
Here is my code in routes/web.php:
Route::prefix('admin')->namespace('Admin')->group(static function() {
Route::middleware('auth')->group(static function () {
//...
Route::resource('profile', ProfileController::class);
});
});
I could not find where the problem is.
Finally, I found out the answer in laravel 8.x upgarade guide. I have texted the controller name with full namespace, instead of importing it.
Route::prefix('admin')->namespace('Admin')->group(static function() {
Route::middleware('auth')->group(static function () {
//...
Route::resource('profile', '\App\Http\Controllers\Admin\ProfileController');
});
});
Run following step for clear route cache
php artisan route:clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With