请帮助我在学校的项目。我如何在 laravel 控制器中查询类似这种情况。我有三个表: Shipping_table 和 Shipping_products 和 tbl_products,现在我的表结构是这样的:
出货表:
Ship_ID (INT AUTO INC)
AMOUNT (DOUBLE,2)
NAME (VARCHAR)
SHIP_DATE (DATE)
RECEIVER (VARCHAR)
运输_产品:
ID (INT AUTO INC)
Ship_id (foreign key from shipping table)
Product_id
Products_table:
Product_id (Auto Inc)
name(varchar)
Qty(int)
Description (varchar)
现在我想要的是这样的查询结果:我想在运输表和子数组中获取所有信息,我想获取在 shipping_products 中列出的具有所需运输 ID 的产品。
像这样的结果:示例我有 2 个 Shipping_table 值
Array(2) {
[0] Array(4) {
['Ship_id'] "1"
['Amount'] "10000"
['Ship_date'] "1995-12-11"
['Ship_products'] Array(3)
['id'] "1" Array(2)
['product_id'] "5"
['name'] "Product 1"
['id'] "2" Array(2)
['product_id'] "6"
['name'] "Product 2"
['id'] "3" Array(2)
['product_id'] "10"
['name'] "Product 15"
}
[1] Array(4) {
['Ship_id'] "2"
['Amount'] "15000"
['Ship_date'] "1995-12-15"
['Ship_products'] Array(2)
['id'] "1" Array(2)
['product_id'] "5"
['name'] "Product 1"
['id'] "2" Array(2)
['product_id'] "6"
['name'] "Product 2"
}
}