How can I define a route differently if parameter is not integer

后端 未结 4 1348
无人及你
无人及你 2021-01-17 08:08

I am using Laravel 5 and working on my local. I made a route with a parameter of {id} and another route with a specific name like so :

Route::get(\'contacts/         


        
4条回答
  •  离开以前
    2021-01-17 09:14

    A simple solution would be to use an explicit approach.

    Route::get('contacts/{id:[0-9]+}', 'ContactController@get_contact');
    Route::get('contacts/new', 'ContactController@new_contact');
    

提交回复
热议问题