I'm trying to insert into product table a form data and one field which i pulled from another table called Purchase by using the code below
Product::create([
'purchase_id'=>$request->product,
'price'=>$price,
'discount'=>$request->discount,
'description'=>$request->description,
'purchase_purchaseprice' => Purchase::where('id',$request->product)->get('price'),
]);
But i get this error message, and i think the issue is this [{"price":"25.00"}]
but i failed to format the query to insert only 25.00 amount, Please help ?
Illuminate\Database\QueryException SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: '[{"price":"25.00"}]' for column
laravel
.products
.purchase_purchaseprice
at row 1 (SQL: insert intoproducts
(purchase_id
,price
,discount
,description
,purchase_purchaseprice
,updated_at
,created_at
) values (262, 4000, 0, ?, [{"price":"25.00"}], 2021-11-19 18:25:59, 2021-11-19 18:25:59))
source https://stackoverflow.com/questions/70039524/laravel-error-inserting-data-into-table-from-another-table
No comments:
Post a Comment