79461819

Date: 2025-02-23 19:18:26
Score: 0.5
Natty:
Report link

I discovered that order is important in declaring laravel routes and that some can be greedy.

the first example doesn't work because the first line takes precedence over the second one

Route::get('/event/{event}', [EventController::class, 'show'])->name('event.show');
Route::get('/event/create', [EventController::class, 'create'])->name('event.create');

The right way to write routes in order is below

Route::get('/event/create', [EventController::class, 'create'])->name('event.create');
Route::get('/event/{event}', [EventController::class, 'show'])->name('event.show');
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: keyon8060