mercredi 16 mars 2016

Laravel 5 pass variable from link in view to route without showing in the URL bar

I try to explain a situation as best as I can and I would like to know what solution would you adopt in this case. Let's say we have a table in the DB with products. Each product has a id, name and other irrelevant properties. I need to have in the address bar this kind of URL:

http://ift.tt/1pnIab4

where mickeymouse is a customized name, pratically is taken from the name field in the database but customized to be more URL friendly.

Now, to manage it, I need a route that will call the controller that will call the new view of the product. And that's the problem. Since mickeymouse is a customized name, even if I pass it to the route, I cant really find it in the database through the controller, cause it's almost impossible to retrieve the original name. So I thought I could pass the ID which is possible to do, but the url would become sorta:

http://ift.tt/1QX9hUW

with 255 as example id and I would like to avoid to show the product id in the URL

Is it possible in laravel 5 to pass a variable (ex:id) from a simple link to a route without showing it in the address bar?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire