我有三张表:1.order_invoices订单表2.order_invoice_productions订单明细表3.productions商品表字段说明:order_invoice订单表id主键idorder_sn订单号money订单金额...order_invoice_productions订单明细id主键IDinvoice_id关联订单表中idproduction_id商品id,关联商品表id....productions商品表id商品idcate商品分类title商品名称price商品价格...问题:1.订单详情,由订单id获得订单的详情,订单与订单明细信息,同时包含商品的名称,分类等等商品属性2.订单列表,同样包含订单,订单明细,商品属性的信息这样的查询该怎么写,在order_invoice模型中hasmany了order_invoice_productions;请各位大大解答一下...谢谢!修改OrderInvoices::where('id',$invoice_id)->with(['orderInvoiceProductions'=>function($query){$query->with(['production'=>function($query){$query->select('title','category_alias');}]);//->select('id','production_id','discounted_price','discount_id','cop_reward')->get();}])->get();返回值:{"id":1,"order_sn":"XT2017071908070144062","total_price":"4800.00","deleted_at":null,"created_at":"2017-07-1908:01:45","updated_at":"2017-07-1909:51:13","order_invoice_productions":[{"id":9,"order_invoice_id":1,"order_sn":"XT2017071908070144062","production_id":1,"deleted_at":null,"created_at":"2017-07-1909:35:49","updated_at":"2017-07-1909:51:13","production":null},{"id":10,"order_invoice_id":1,"production_id":2,"deleted_at":null,"created_at":"2017-07-1909:35:49","updated_at":"2017-07-1909:51:13","production":null}]}
肥皂起泡泡
相关分类