Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add extra parameter with full url in laravel blade?

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?

like image 878
Nabil Farhan Avatar asked Feb 19 '19 09:02

Nabil Farhan


People also ask

How do you add multiple parameters to a URL?

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.

What is source parameter in URL?

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.

How can I get laravel URL ID?

$request->id; You can get id from POST method like this. public function getDetail(Requests $rq){ $product = Product::where('id',$rq->id)->get(); } .


1 Answers

As suggested from @joão-henrique-silveira I add my comment as an answer for better visibility.

{{ request()->fullUrlWithQuery(['foo' => 'bar']) }} 
like image 160
superfly Avatar answered Sep 20 '22 15:09

superfly