2 weeks ago

Hashing ID in URL.

Posted 2 weeks ago by oli_d111

Afternoon all.

I hope everyone is well?

I'm looking to hash the user ID in the URL to prevent any funny business inside of the profile page.

After some googling around there appear to be a lot of different tutorials and suggestions but some are un clear on all of the steps or are missing steps from what i can tell.

I was hoping you kind folk would be able to point me in the right direction?

Currently i'm calling the page as follows:-

<a class="nav-link" href="{{ route('customer-profile.show', Auth::user()->id) }}">

Route::get('customer-profile/{id}', 'Customer\[email protected]')->name('customer-profile.show');

public function show(Request $request, $id)

Of which then shows customer-profile/2 which isn't ideal.

I tried Vinkla/Hashids on this tut https://sampo.co.uk/blog/masking-ids-in-urls-using-hash-ids-in-laravel but it didnt seem to work for me. Also found Hashids/Hashids but couldnt find a good tut on it.

Any advice would be greatly appreciated.

Thanks in advance all.

Please sign in or create an account to participate in this conversation.