I have a url with some query string. I know I can get the full string with url()->full()
. But I want to add extra query string with it. And there I am facing problem.
So far I have tried, href={{ url()->full()."&rating=5" }}
This is working fine if there is already some query data in the url. But if there is none then it is showing error.
Example: If my url is example.com/147?place=33
then it works but if my url is example.com/147
then it doesn't work.
I also tried, href={{ url()->full()."?rating=5" }}
. This is working only in the opposite scenario.
How can I append my own query string after the full url regardless of the existence of current query?
To add a parameter to the URL, add a /#/? to the end, followed by the parameter name, an equal sign (=), and the value of the parameter. You can add multiple parameters by including an ampersand (&) between each one.
Also known by the aliases of query strings or URL variables, parameters are the portion of a URL that follows a question mark. They are comprised of a key and a value pair, separated by an equal sign. Multiple parameters can be added to a single page by using an ampersand.
$request->id; You can get id from POST method like this. public function getDetail(Requests $rq){ $product = Product::where('id',$rq->id)->get(); } .
As suggested from @joão-henrique-silveira I add my comment as an answer for better visibility.
{{ request()->fullUrlWithQuery(['foo' => 'bar']) }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With