7

I know this one

{{route('editApplication', ['id' => $application->id])}} == /application/edit/{id}

But I need

?? == /application/edit?appId=id

Anyone, please replace the "??" with your answer that helps me out.

1
  • Can you please elaborate more about what you want to achieve, where you want to achieve? Commented Jan 8, 2020 at 6:28

3 Answers 3

25

It depends how you route looks like:

If you route is:

Route::get('/application/edit/{id}', 'SomeController')->name('editApplication');

when you use

route('editApplication', ['id' => 5])

url will be like this:

/application/edit/5

However all other parameters (that are not in route parameters) will be used as query string so for example:

route('editApplication', ['id' => 5, 'first' => 'foo', 'second' => 'bar'])

will generate url like this:

/application/edit/5?first=foo&second=bar

In case you want to achieve url like this

/application/edit?appId=id

you should define route like this:

Route::get('/application/edit/', 'SomeController')->name('editApplication');

and then when you use

route('editApplication', ['appId' => 5])

you will get

/application/edit?appId=5

url.

Sign up to request clarification or add additional context in comments.

1 Comment

HIGHLY IMPRESSIVE AND CORRECT ANSWER, Thanks Marcin Nabialek :)
2

You need to modift your "editApplication" route without parameter option. If you stil want the parameter just add the following row in your controller and just catch the data by using;

$appId = $request->input('appId');

Comments

1

route method accepts any set of variable and puts them as query string unless the variable name matches with defined route signature.

Thus, for your case you can do something as follows:

route('editApplication', ['appId' => <your id here>])

You can provide any number of variables with the array.

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.