I have an error
Missing required parameter for [Route: updatetransaksi] [URI: penjualan/update/{id}] [Missing parameter: id].
web code
route::get('/penjualan/edit/{id_penjualan}', [PenjualanController::class, 'edit']);
route::post('/penjualan/update/{id}', [PenjualanController::class, 'update'])->name('updatetransaksi');
controller code
public function edit(string $id_penjualan)
{
$penjualan = Penjualan::where('id_penjualan', $id_penjualan)->first();
$penjualan = DetailPenjualan::with('Penjualan', 'Barang')->where('id_penjualan', $id_penjualan)->get();
$penjualanData = Penjualan::with('pembeli', 'detailPenjualan.barang')->find($id_penjualan);
$pembeli = Pembeli::find($id_penjualan);
$barang = Barang::all();
return view('penjualan.edit', compact('penjualan', 'penjualanData', 'pembeli', 'barang', 'id_penjualan'));
}
public function update(Request $request, $id_penjualan)
{}
view code
<form action="{{ url('updatetransaksi', ['id' => $id_penjualan]) }}" method="POST">
how to solve this error
2
Answers
Your controller method and route parameter don’t match. You either change your route definition from this:
to this:
or your controller function definition from this:
to this:
Either way works fine.
In Form