Reputation: 481
I'm trying to pass two variables/arguments from my view through a link
<a href="{{ route('shop.order.test', $id,$form['grouping']) }}"
and call the route
Route::get('ordering/test', 'Shop\OrderingController@testing')
->name('shop.order.test');
And call this function with those two arguments
public function testing($id,$grouping){
}
It doesn't seem to be working though. Is my error in my route or my link call?
Upvotes: 1
Views: 5234
Reputation: 418
To pass parameters in a route use an array with the paramter names as keys:
{{ route('shop.order.test', ['id' => $id, 'grouping' => $form['grouping']]) }}
Upvotes: 2
Reputation: 15089
If you want to have parameters to be passed into controller's method, you need to define route parameters like this
Route::get('ordering/test/{id}/{grouping}', 'Shop\OrderingController@testing');
then you can have it in controller method:
public function testing($id, $grouping)
To generate route for above definition, the second parameter is the array of params to pass. So it will become
{{ route('shop.order.test', ['id' => $id, 'grouping' => $form['grouping']) }}
Upvotes: 3