I'm having a problem with my get route in a group. here is my code:
Route::group(['prefix' => 'commodities'], function(){
Route::get('commodities', [
'as' => 'showCommodities', 'uses' => 'CommodityController@showAll'
]);
Route::get('{id}', [
'as' => 'showCommodity', 'uses' => 'CommodityController@show'
]);
Route::get('add', [
'as' => 'addCommodity', 'uses' => 'CommodityController@create'
]);
Route::post('update', [
'as' => 'updateCommodity', 'uses' => 'CommodityController@update'
]);
Route::post('destroy', [
'as' => 'destroyCommodity', 'uses' => 'CommodityController@destroy'
]);
Route::post('add', [
'as' => 'storeCommodity', 'uses' => 'CommodityController@store'
]);
});
I pasted the CommodityController
code here http://pastebin.com/bWrdVhsv
Everything works except the GET route commodites/add
. I always get a white page. My debug is set to TRUE
and I have the correct blade for it.
Am I missing something here?
The problem is the order of your routes.
Move the
add
route above your catch all{id}
route.Laravel will go through your routes.php file top to bottom. The below route is essentially a catch all.
This means it will catch all GET requests to urls that match the pattern:
/commodities/some-kind-of-string
.As the
/commodities/add
uri matches the above pattern it will use that route because it appears first in the routes file.