I get this error when I try to insert an object in laravel, this is my function in the controller class:
public function insertDelete(Producto $item) { $date = date('Y-m-d'); $venta=new venta(); $venta->fechaVenta=$date; $venta->user_id=$item->user_id; $venta->producto_id=$item->id; $venta->envio_id=$item->envio_id; $venta->save(); Producto::where('id',$item->id)->delete(); return view('pruebas');}
My route:
@foreach ($ticket as $item)<div class="d-flex my-2 justify-content-center"> <a href="{{ route('insertDelete' , $item) }}" class="btn btn-success btn-label waves-effect right waves-light rounded-pill"><i class="ri-check-double-line label-icon align-middle rounded-pill fs-16 ms-2"></i> Finalizar Compra</a> </div>@endforeach
My web.php
Route::get('pruebas/', [\App\Http\Controllers\VentaController::class, 'insertDelete'] )->name('insertDelete');
In your route, you do not specify the parameters of the route model binding. You are expecting
$item
, in which case you want something like this: