如何在laravel 5.2中返回作为数组对象加入的表的值

时间:2017-04-13 06:17:29

标签: php frameworks laravel-5.2

我有2张桌子: 的订单(ORDER_ID,order_code,USER_ID,FULL_NAME,电话,地址,recieve_address,total_product,TOTAL_PRICE,状态,created_at,的updated_at)

detail_order (ID,ORDER_ID,order_code,PRODUCT_ID,价格,数量,TOTAL_AMOUNT,created_at,的updated_at)

如何在laravel中连接2个表时编写查询以返回表详细信息顺序的值?

array:1 [▼
  0 => {#194 ▼
    +"order_id": 37
    +"order_code": "Order00003"
    +"user_id": 1
    +"full_name": "Duc.VUong"
    +"phone": "01203388870"
    +"address": "445/33b bình đông"
    +"recieve_address": "445/33b bình đông"
    +"total_product": 2
    +"total_price": 1450000.0
    +"status": 0
    +"created_at": "2017-04-12 17:01:38"
    +"updated_at": "2017-04-12 17:01:38"
    +"detail":[
    0=>{
        +"product_id": 1
        +"price": 800000.0
        +"quantity": 1
        +"total_amount": 800000.0
    }
    1=>{
        +"product_id": 2
        +"price": 650000.0
        +"quantity": 1
        +"total_amount": 650000.0
    }
    ] 
  }
]

0 个答案:

没有答案