Khudadad's avatar

How to hide url parameter

I wana edit auth user account, when I click on account link the parameter is shown in the url like so,

http://localhost:8000/settings/account/4/edit

and I wana be like this

http://localhost:8000/settings/account

Not using hidden field of a form, just as a link if there is a solution. Thanks

0 likes
8 replies
Khudadad's avatar

It's a link how to do that.

<a href="{{ url('/settings/account',Auth::user()->id) }}/edit">Update Account </a>

when I change the route like so:

Route::post('settings/account/{id}/edit','UserController@editProfile');

then I get this error

MethodNotAllowedHttpException in RouteCollection.php line 219:
mke-media's avatar

You only need to register a second route, and then solve it in the method itself, by checking if you have an user id or not.

if not, you can get it from Auth::user()->id

Or am i wrong?

Khudadad's avatar

auth user id should be passed to update method in the controller and it is passed and as you see above at the link,so I want to hide this param I mean should not be displayed in the url.

jekinney's avatar

In your controller set your query by how ever and return the view and data with out using data in the url.

@mke-media yes auth()->user()->Id is an option but auth()->id() is faster.

pmall's avatar

Use auth()->id() instead of the url parameter thats all.

Please or to participate in this conversation.