Domanda

localhost/public/Products-product-name1 //Product names are alphanumeric
localhost/public/Products-product-name2
localhost/public/Products-product-name3
localhost/public/Products-product-name4
......

How to give single root for the url's having following prefix Products-

Route::post('Products-','ProductsController@getProducts');

Can anyone suggest me.

È stato utile?

Soluzione

you could simply use route parameters:

Route::post('Products-{product}', 'ProductsController@getProducts');

and inside your controller:

public function getProducts($product = 'product-name1')
{
    ...
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top