other order of method in route makes blank page

69 Views Asked by At

I have a little problem ( Laravel 5.0 ) with routing. When I put this in routes.php

Route::get('admin/tags', 'Admin\TagController@index');
Route::get('admin/tags/{id}','Admin\TagController@show');
Route::get('admin/tags/create', 'Admin\TagController@create');

last route admin/tags/create show blank page. but when i change order to ( create 1st )

Route::get('admin/tags/create', 'Admin\TagController@create');
Route::get('admin/tags', 'Admin\TagController@index');
Route::get('admin/tags/{id}','Admin\TagController@show');

everything is ok and admin/tags/create view showing content.

1

There are 1 best solutions below

0
On

when the users asks for
/admin/tags/create
the requested url will also match
Route::get('admin/tags/{id}','Admin\TagController@show');
because it can pars your "create" word as the {id} part of the route definition.
to solve this, you can use some reqular expressions that describe your {id} as an string, consists of numbers 0-9 .