Reputation: 33
i would know how i can insert all my controllers in routes without repeat use.... use...
example:
<?php use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DB;
use App\Http\Controllers\DB1;
use App\Http\Controllers\DB2;
use App\Http\Controllers\DB3;
use App\Http\Controllers\DB4;
use App\Http\Controllers\DB5;
use App\Http\Controllers\DB6;
etc.....
Route::get('/', function () {
return view('welcome');
});
How can i insert a lot of controllers in only one time?? Thanks a lot.
P.S. DB1,DB2,etcc are example XD
Upvotes: 3
Views: 1015
Reputation: 3027
to work with web.php
and routing
in laravel 8 the same as previous ones, which you don't need to import the controllers. you can do the following work:
App\Providers\RouteServiceProvider.php
add $namespace
class RouteServiceProvider extends ServiceProvider {
// add this line
protected $namespace = 'App\Http\Controllers';
}
$namespace
to boot
method of RouteServiceProvider
:public function boot() {
//...... other codes
//add the below code
$this->routes(function() {
Route::middlware('web')->namespace($this->namespace);
});
}
Upvotes: 2
Reputation: 2545
You can do
use App\Http\Controllers\{DB, DB1, DB2, ...};
More reference Here
Upvotes: 0