Define defaults() in Routes

  • Laravel

Pre-fill route parameters so your URLs stay clean:

1Route::get('reports/{year}/{month}', ReportController::class)
2 ->defaults('year', now()->year)
3 ->defaults('month', now()->month);

Now /reports will automatically fill with the current year and month if omitted.