mySun
mySun

Reputation: 1696

How to create dynamic route in Laravel?

I create compare page for products,

I need create route for compare page, How to create dynamic route in Laravel 5.3?

For example:

https://www.mywesite.com/Compare/DKP-181451/DKP-254287/DKP-254282/DKP-227429/DKP-254282

This page is 5 product for compare.

Or:

https://www.mywesite.com/Compare/DKP-181451/DKP-254287

This page is 2 product for compare.

Upvotes: 2

Views: 1018

Answers (1)

apokryfos
apokryfos

Reputation: 40653

The following will probably work:

 Route::get("Compare/{any}", function ($any) {
       $productsToCompare = explode("/",$any);
       // Compare products.


 })->where("any", ".*");

Upvotes: 2

Related Questions