hiding id the LARAVEL url

Asked

Viewed 181 times

2

Good morning guys, someone help me I’m trying to hide the id.

as it appears: http://localhost:8000/admin/client/edit/1

I want it to stay that way http://localhost:8000/admin/client/edit

without displaying the id

button

<a href="{{route('admin.editar.cliente', ['id' => $cliente->id])}}" class="btn btn-success"><i class="fa fa-edit"></i></a>

controller

 public function edit($id)
{
    $id = base64_decode($id);
    $cliente = Cliente::with('user')->where('id', $id)->first();//pega primeiro resultado
    return view('cliente.editar', compact('cliente'));//pega os cliente clicado

}

web php.

Route::get('cliente/editar/{id}', 'ClienteController@edit')->name('admin.editar.cliente');
  • You can use Hashids. Please follow the link below: <https://coderwall.com/p/gt1zkg/laravel-hidden-id>

  • And when accessing /admin/cliente/editar, how to know which client you want to edit?

  • i just wanted to hide, not keep showing to the user @Andersoncarloswoss

  • Yes, but your application will need to fetch this value from somewhere to know which record to search in the bank. Today it looks for the URL, if you take it from there you will need to search from somewhere else.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.