Reputation: 505
Missing argument 2 for App\Http\Controllers\Company\OrderController::store()
I got this error in my store controller, my form is passing 2 parameters but the second one is not found.
Route: Route::resource('order', 'OrderController'); $company gets converted to a model in the controller.
The form:
<form class="form-horizontal" role="form" method="POST" action="{{action('Company\OrderController@store', [$company,$orderid])}}">
{{ csrf_field() }}
<button type="submit" class="btn btn-primary">Accept</button>
</form>
Any ideas?
Thanks!
Upvotes: 1
Views: 138
Reputation: 13693
You should specify the key-value
pair like this:
['company_id' => $company->id, 'order_id' => $order->id]
So your form would look like:
<form action="{{ action('Company\OrderController@store', ['company_id' => $company->id, 'order_id' => $order->id]) }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-primary">Accept</button>
</form>
Hope this helps!
Upvotes: 1
Reputation: 163748
If you created store
route with Route::resource()
it doesn't expect any parameters and should look like this:
public function store(Request $request)
So, you need to pass data using hidden inputs, like:
{!! Form::hidden('data', 'some data') !!}
And then get data in controller with:
$data = $request->data;
Upvotes: 2