Slug and Post/Get on the same Route - Laravel

Asked

Viewed 355 times

1

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

My current code is above and is working. I did this by the fact that if I leave only 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 as long as I have a Slug.

In this Controller I also have a postPagina(). That’s why I did the Route from the bottom line. But I don’t know if it’s the best way. There’s how to do it in just one Route ?

In my Productocontroller has:

public function getIndex($slug = null)
public function postInsertProduto()
  • Use stacksnippet only to play problems with css, html and js that can be run.

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.