I add user_id, product_id with an extra field. Everything works fine until the extra field is updated. When the field is filled a second time instead of updating, it will add another one to the database. and this is obvious because I used binding instead of synchronization. But when I use synchronization, I get an error message.
this is my code:
$price = $request->input('price');
$product = Product::find($id);
$product->users()->attach(Auth::id(), ['price' => $price]);
and this is the error I get when using synchronization:
Argument 1 went to Lighten \ Database \ Eloquent \ Relations \ BelongsToMany :: formatRecordsList () must be an array of types, integer given
source
share