1

I need to hide the url value in php as i have a booking site and users are able to edit their reservation through the URL if needed.

This is how the URL link looks like.

http://spiaggiasanmontano.it/booking/S12/2021-06-11/2021-06-12/0

i'm trying to remove the dates in the URL without breaking the code, any idea how i can do this?

And this is the route controller for it.

Route::get('/booking/{place_id}/{checkin}/{checkout}/{error_msg}', 'PagesController@createbooking')->name('user.createbooking');
4
  • 2
    why don't just use post request then?? Commented Jun 10, 2021 at 6:57
  • basically replace the ::get with ::post right? Commented Jun 10, 2021 at 6:58
  • yeah, submit the form with post request and remove the route parameters if you don't want them in the url. Commented Jun 10, 2021 at 7:02
  • What exactly do you want to achieve? Where are you stuck? If such data is not relevant, why not simply remove it? Wouldn't it be better to use a single, unique identifier per booking, instead of multiple values? Commented Jun 10, 2021 at 8:24

1 Answer 1

2

You can use laravel Encrypter if you still wants to pass it in url with encrypted value instead of displaying orginal value

for example checkin date

pass encrypted date to url encrypt(checkin) value

encrypt(checkin)

then in your controller you can decrypt it

 $checkinDate= decrypt($checkin);

For example if have link like below in blade

<a href="{{route('user.createbooking',['palceid',encrypt($checkin)])}}"/>

Ref:https://laravel.com/docs/8.x/encryption#using-the-encrypter

Sign up to request clarification or add additional context in comments.

2 Comments

Is this the right way to write it in the URL route? : Route::get('/booking/{place_id}/{encrypt(checkin)}/{encrpt(checkout)}/{error_msg}', 'PagesController@createbooking')->name('user.createbooking');
@tamerjar.its not in route .you have to write it in blade where you pass url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.