2

I'm trying to create a link that leads to www.website.com/account/payments?status=verified

Here's the code

<a href="{{ url('account/payments', ['status' => 'verified']) }}">Verified</a>

However the above is leading me to www.website.com/account/payments/verified

Is there any way to achieve what i want without using the controller?

1 Answer 1

2

There's a discrepancy between url() and route() in regards to the second (array) argument. Using the latter your function call will work as expected when status isn't defined as a route parameter; it'll tack it on to the path as a query string.

// in routes file
Route::get('account/payments', 'Controller@method')->name('account.payments');


route('account.payments', ['status' => 'verified']);
// www.website.com/account/payments?status=verified

The url() function however simply appends all elements of the second argument onto the supplied path instead of a query string. Still, it's possible to define an inline query string:

url('account/payments?status=verified')
// www.website.com/account/payments?status=verified

Here's another example to see how url() handles the second argument. It merely inserts the "extra" path segments:

url('account/payments?status=verified', ['bar'])
// www.website.com/account/payments/bar?status=verified
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.