Slug and Post / Get on the same Route - Laravel

0
# PÁGINA DE PRODUTO - RELACIONADA AO CARRINHO
Route::get('produtos/{slug?}', 'ProdutoController@getIndex');
Route::controller('produtos', 'ProdutoController');

My current code is the one above and it's working. I did this by the fact that if I just leave the bottom line it does not find the Controller in the following URL with slug - localhost / site / public / products / my-slug-product . So I set a Route just for how long it has a slug.

In this Controller I also have a postPage () . So I made the route down the line. But I do not know if it's the best way. Can you do this on just one Route?

In my ProductController you have:

public function getIndex($slug = null)
public function postInsertProduto()
    
asked by anonymous 16.04.2015 / 14:34

1 answer

0

Resolved.

Route::any('produtos/{slug?}', 'ProdutoController');

And in ProductController.php I did:

public function anyIndex($slug){

}

link

    
08.09.2015 / 16:20