Reputation: 1149
Let's say my project root is http://localhost/laravel-project
In the project I have navigation menu, the sample format of the link is
<a href="home">home</a>"
So when I click the link the url on my browser is http://localhost/laravel-project/home
I do not know why if I have another link
<a href="invoice/show/1">home</a>"
and the route is Route::get('/invoice/show/{id}', 'Frontend\CommonController@show');
when I click the link, the previous home link will become
http://localhost/laravel-project/invoice/show/member
it's supposed to be http://localhost/laravel-project/home
.
The inside show method :
public function show(){
return view('frontend.invoice', ['subaccounts' => $this->subaccounts, 'menus' => $this->menus]);
}
I have tested it, the cause of the problem is the segments on the link invoice/show/1
if the link is only invoice
then everything is fine.
Anyone knows what is wrong and how to solve this issue ?
Note : I am using a blade template
Upvotes: 2
Views: 2227
Reputation: 1149
I managed to solve the problem by using the function {{url('linkName')}}
in the link.
Upvotes: 1