Issue
I have an Admin folder with UserController (resource) inside
--Controllers
--Admin
-- UserController.php
In web.php I have the following routes:
use App\Http\Controllers\Admin\UserController;
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function (){
Route::get('/', [HomeController::class, 'index']);
Route::resource('user', UserController::class);
});
UserController
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function index()
{
return view('admin.user.index');
}
}
When I try to go to admin/user I get an error
Target class [Admin\App\Http\Controllers\Admin\UserController] does not exist.
I will be grateful for the hint.
Solution
You set the namespace to Admin so it adds it in the base namespace. Just remove the namespace. It should work.
Route::group(['prefix' => 'admin'], function (){
Route::get('/', [HomeController::class, 'index']);
Route::resource('user', UserController::class);
});
Answered By - Karl Mounguengui Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.