5

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.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Md. Robi Ullah
  • 1,703
  • 3
  • 20
  • 32

3 Answers3

20

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.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
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');
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.

Pusparaj
  • 1,469
  • 1
  • 12
  • 19