Reputation: 55
i have an url with parameter such as
http://localhost:8000/search_doctor_home?specialty_id=1
and I have a get form and I need the new parameter to the current parameters so it is going to be
http://localhost:8000/search_doctor_home?specialty_id=1°ree_srch=4
not
http://localhost:8000/search_doctor_home?degree_srch=4
and I tried the following methods but it does not work
<form method="GET" action="{{ url()->full() }}">
and
<form method="GET" action="{{ request()->fullUrlWithQuery(['degree_srch' => 4]) }}">
Upvotes: 3
Views: 1303
Reputation: 825
You can get the current query array by request()->query()
, and merge the new params with the query array and appends to the url:
request()->fullUrlWithQuery(array_merge(request()->query(), ['degree_srch' => 4]));
or
route('your_route_name', array_merge(request()->query(), ['degree_srch' => 4]));
Upvotes: 3