I have 2 links on the same view where I'm calling the same route with different parameters:
<a href="{{ route('getalladdress', ['addressType' => 'customer']) }}">Customer Address</a>
<a href="{{ route('getalladdress', ['addressType' => 'tax']) }}">Tax Address</a>
Route:
Route::get('getalladdress/{addressType}', 'AddressController@getalladdress');
Controller:
public function getalladdress($addressType) {
//some code
return view('partials.searchaddress')
->with('addressType', $addressType);
}
When I'm clicking on the first link, the addressType parameter is returning correctly, i.e., "customer". When I'm clicking on the second link, the addressType parameter is returned as the first one "customer" instead of "tax". I don't know what I'm doing wrong here. Any help would be appreciated. Thanks!
PS: I'm a newbie to Laravel.
To use the
route()
helper function, you need to give your routes names.Then you can use the route name with the helper as follows: