lundi 22 octobre 2018

How to pass vehicle id to another controller function in Laravel 5.6?

I need find relevant vehicle id and update some column values. I have following link to some form.

<a class="btn btn-primary" href="" role="button">Go Premium</a>

now I have following form in payment.blade.php

<form method="post" action="">

<input type="hidden" id="adtype" name="adtype" value="1" />
<input type="submit" name="submit" value="Submit">
</form>

now I need update vehicles table adtype values from 0 to 1 when click submit button of above form. I have following addorder function in PaymentController,

public function addOrder(Request $request)
{
$vehicle = Vehicle::find($id);
$vehicle->adtype = $request->input('adtype');
$vehicle->save();
}

and route is this,

Route::post('add-order', 'PController@addOrder');

but I got following error,

 ErrorException
    Missing argument 2 for App\Http\Controllers\PController::addOrder()

how can fix this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire