Make sure your namespace is correct
Sep 11, 2020
6
Level 1
Target class [CarrierController] does not exist.
Illuminate\Contracts\Container\BindingResolutionException Target class [CarrierController] does not exist.
I have a navigation with a mega menu with this link http://localhost:8000/about-us/carrier
how can I make it dynamic the router? Can anyone help me to know the codes of route? and controller?
Level 9
@eliasniyonsaba If you are using Laravel8 do this.
To App/Providers/RouteServiceProvider.php add $namespace
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
}
and this
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->namespace($this->namespace) // add this line
->group(base_path('routes/web.php'));
Route::prefix('api')
->middleware('api')
->namespace($this->namespace) // and this line
->group(base_path('routes/api.php'));
});
}
2 likes
Please or to participate in this conversation.