문제

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.

도움이 되었습니까?

해결책

you could simply use route parameters:

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

and inside your controller:

public function getProducts($product = 'product-name1')
{
    ...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top