Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ollie_123's avatar

Routing issue when user ID is in URL...

Hi All

I'm just working on the user profile page and i have a weird issue that i can't figure out.

When i select the user profile page, the page loads and gives me the URL of eg... ...dealer-profile/2

However when i click to navigate to another page...say dashboard, it tries to add the URL of the existing URL so it ends up as dealer-profile/2dashboard

The way i've got it set up is Navbar:

<a class="nav-link" href="{{ route('dealer-profile.show', Auth::user()->id) }}">
	<i class="fas fa-user-cog" aria-hidden="true"></i>
	<span>Profile</span>
</a> 

& my route is:

Route::get('dealer-profile/{id}', 'Dealer\ProfileController@show')->name('dealer-profile.show');

I tried adding a / after {id} but no joy.

Please can someone advise how i would go about resolving this?

Thank you in advance.

0 likes
6 replies
Sinnbeck's avatar

Can you show that dashboard link? Most likely that is the issue

ollie_123's avatar

I just realised. Its because I'm not using a leading / in my anchor tags.

Doh!....

Thanks dude :)

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You need to either use a named route (like your dealer-profile) or add a slash in front of dashboard

<a class="nav-link" href="/dealer-dashboard">.
Sinnbeck's avatar

Oh I see you got it yourself. Was to slow typing :p

Please or to participate in this conversation.