3๐
โ
You are filtering the collection with where()
after you get all the product_materials from the DataBase.
Change it to this and it will solve your issue. aka apply the condition before getting the results from database (way better performance too)
$product_materials = product_materials::where('product_id', $product->id)->get();
๐คN69S
0๐
this is not related to vuejs, try to return the product_materials as array of objects even for one object
it should be like this
"product_materials": [
{
"id": 12,
"product_id": 2,
"description": "Wood",
"quantity": 10,
"rate": "5.000",
"amount": "50.000",
"delete": 0,
"created_at": "2022-04-09T10:27:21.000000Z",
"updated_at": "2022-04-09T10:27:21.000000Z",
"created_by": 1,
"updated_by": null,
"deleted_by": null
}
]
๐คAhmed Hassan
0๐
use :
$product_materials = product_materials::query()
->where('product_id', $product->id)
->get();
OR :
$product_materials = product_materials::query()
->where('product_id', $product->id)
->first()();
๐คAlirezaAhmadi
Source:stackexchange.com