How to encrypt laravel 5.2 URL or Routes?

后端 未结 7 853
情歌与酒
情歌与酒 2020-12-19 10:51

I need to encrypt routes in this URL? Because I do not want user to access URL by changing the item id. For example, user can change /items/1234 to /item/5678. Although item

7条回答
  •  星月不相逢
    2020-12-19 11:05

    You don't want to encrypt all routes, it's bad practice. You can use encrypt() helper to encrypt parameter and decrypt() to decrypt it.

    $encryptedId = encrypt($id);
    

    https://laravel.com/docs/5.3/encryption#using-the-encrypter

提交回复
热议问题