J. Kosiński
J. Kosiński

Reputation: 48

Way to prefix controllers

Is there any way to set custom folder controllers prefix like routes in laravel 5.6?

Route::get("/", "Foo/Controller@method");
Route::post("/", "Foo/Bar/Controller@method");
Route::get("/index", "Foo/Bar/Controller/Controller@method");

I want this

Route::get("/", "Foo::Controller@method");
Route::post("/", "Foo::Bar.Controller@method");
Route::get("/index", "Foo::Bar.Controller.Controller@method");

Upvotes: 1

Views: 181

Answers (1)

Devon Bessemer
Devon Bessemer

Reputation: 35347

No, but you can group your routes and set a starting namespace for the entire group:

Route::group([
    'namespace' => 'Foo'
], function () {
    Route::get("/", "Controller@method");
    Route::post("/", "Bar\\Controller@method");
});

Upvotes: 1

Related Questions