Search code examples
phplaravellaravel-5laravel-5.3

Add static route to a route the is supposed to be dynamic?


In my routes file, web.php I have,

Route::get('/m/{game}', 'CommentController@index')->name('game');
Route::get('/m/{game?}', 'GameController@all')->name('all');

But can I add "static" routes, for example:

Route::get('/m/snes', 'GameController@snes')->name('snes')

Solution

  • Arrange your routing to make the static at top, so laravel routing will find the static first rather than go to the /m/{game} and /m/{game?}