Reputation: 349
I am new to Laravel 4, and I am trying to develop a simple employee CRUD system.
If I want to update a record, I have to access "domain/laravel/employee/1" it means that "1" represents as employee ID. Is there a function in Laravel 4 that I can set to encrypt the ID automatically?
Or maybe there is a better way instead of ID encryption?
Upvotes: 0
Views: 2434
Reputation: 1
For that purpose you have to follow 2 steps
encrypt id in blade file
<a href="/product/{{ encrypt($product->id) }}">Delete</a>
decrypt id in controller or web.php file $decrypted_id = decrypt($id);
Upvotes: 0
Reputation: 7947
It is not the best practice. If you encrypt the id using Crypt::encrypt($id)
, then the url will be
domain/laravel/employee/eyJpdiI6IjltdEJraDN3SWdGa21hTktodWdq
This is not easily predictable. Use Crypt::decrypt($id)
to decrypt the id.
Upvotes: 1