I have separated my project routes into home.php that contains the client-side routes and admin.php that contains server-side routes.
So here is my RouteServiceProvider.php:
public function boot() { $this->configureRateLimiting(); $this->routes(function () { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web/home.php')); Route::middleware(['web', 'auth.admin']) ->namespace($this->namespace . '\Admin') ->prefix('admin') ->group(base_path('routes/web/admin.php')); }); } So as you see I have specified ->namespace($this->namespace . '\Admin') because of Admin Controllers that are placed in this directory:
App\Http\Controllers\Admin\...
Then in the admin.php, I added this route:
Route::resource('users', UserController::class); But I get this error:
Target class [Admin\UserController] does not exist. So what's going wrong here? How can I solve this issue and properly call the Controller from Admin?
namespace App\Http\Controllers\Admin;