How to hide the url in laravel when you use get to edit?


I want to edit a record using its id and I have the following code in my view:

<a href="{{route('guest.edit',$g->id)}}" class="btn btn-simple btn-warning btn-icon edit"><i class="ti-pencil-alt"></i></a>

And so I have on my route:


Then on my controller:

public function edit($id){
    return view('Guests.edit1',compact('guest'));

The problem with this is that the id appears on my route, which I think is not safe, appears like this


How do I fix it in such a way that the id is not shown in the url, or the url is not displayed at all

asked by lucho 08.11.2017 в 20:29

4 answers


A possible solution would be to use Encryption to display its encrypted parameter. From the view, I would use encrypt from blade

<a href="{{route('guest.edit',Crypt::encrypt($g->id))}}"

Then in the controller decrypt this value.

public function edit($id){
  $id =  Crypt::decrypt($id);
  return view('Guests.edit1',compact('guest'));

Do not forget use Illuminate\Support\Facades\Crypt;

answered by 08.11.2017 / 21:03

I found the best solution to the problem using FakeID .

Masks all the ids of your model, simply by placing the namespace and the trait , it will hide your id and it will generate a very clean URL, example, if you have something like this:


I'll change it for something like this:


You do not have to worry about encrypting or decrypting , it does everything automatically.



answered by 30.07.2018 в 23:33

You could also try it with the use of friendly urls, you have a cleaner url and you manage to hide the id.

I use this package link allows you to generate friendly url in a simple way.

answered by 31.07.2018 в 22:50

Try it this way with an alias on the route:

   'uses'=>'[email protected]',

or also with this laravel helper:

answered by 08.11.2017 в 20:45