Route işlemlerinin daha düzenli olması için web.php veya api.php dosyasından farklı bir dosyaya koymak isteriz. Bugün yeni bir Route dosyasının nasıl oluşturulacağını öğreneceğiz.
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
//ekle
'static' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
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.php'));
//ekle
Route::middleware('static')
->namespace($this->namespace)
->group(base_path('routes/static.php'));
});
}
Yeni route dosyamız hazır.