【发布时间】:2019-06-18 11:19:58
【问题描述】:
这是查看路线
public function showOrder(Order $order)
{
return view('return.sales-return-show', compact('order'));
}
这是 dd($order); 的输出
#original: array:18 [▼
"id" => 7
"company_id" => 1
"order_type" => 1
"order_no" => "12"
"date" => "2019-01-16"
"status" => "1"
"transaction_raw" => "[{"amount":"82264","transaction_type":3,"payment_type":1,"owner_type":"App\\Model\\Customer","owner_id":"1"},{"amount":"0","transaction_type":4,"payment_type":1 ▶"
"line_items" => "[{"customer_id":"1","product_id":"10","unit_id":"2","quantity":"5","price":"2700","total_price":"13500"},{"customer_id":"1","product_id":"43","unit_id":"1","quantity":"52","price":"7","total_price":"364"},{"customer_id":"1","product_id":"9","unit_id":"2","quantity":"18","price":"3800","total_price":"68400"}] ◀"
"total" => 82264.0
"discount" => 0.0
"sub_total" => 82264.0
"paid" => 0.0
"due" => 82264.0
"supplier_id" => 0
"customer_id" => 1
"others_fin" => "{"transport":"0","type":"income"}"
"created_at" => "2019-01-16 19:13:27"
"updated_at" => "2019-01-16 19:13:27"
]
这是我可以显示产品名称的循环
@foreach($order->items as $item)
{{$item->product->name}}
@endforeach
这是我的 json 路由
public function json(Order $order)
{
return response()->json(['orders' => $order]);
}
JSON 数据:
{ “命令”:{ “身份证”:7, “公司ID”:1, “订单类型”:1, "order_no":"12", "日期":"2019-01-16", “状态”:“1”, “transaction_raw”:[ { “金额”:“82264”, “交易类型”:3, “付款类型”:1, "owner_type":"App\Model\Customer", “所有者 ID”:“1” }, { “金额”:“0”, “交易类型”:4, “付款类型”:1, "owner_type":"App\Model\Customer", "owner_id":"1", “account_head_id”:1 } ], “line_items”:[ { "customer_id":"1", "product_id":"10", "unit_id":"2", “数量”:“5”, "价格":"2700", “总价格”:“13500” }, { "customer_id":"1", "product_id":"43", "unit_id":"1", “数量”:“52”, “价格”:“7”, “总价格”:“364” }, { "customer_id":"1", "product_id":"9", "unit_id":"2", “数量”:“18”, "价格":"3800", “总价格”:“68400” } ], “总计”:82264, “折扣”:0, “小计”:82264, “付费”:0, “到期”:82264, “供应商 ID”:0, "customer_id":1, "others_fin":"{\"transport\":\"0\",\"type\":\"income\"}", "created_at":"2019-01-16 19:13:27", "updated_at":"2019-01-16 19:13:27" } }
现在我需要在此处显示产品名称
<tr v-for="order in orders.line_items">
<td></td>
<td><input name="" v-model="PRODUCT NAME" class="form-control"></td>
<td>{{order.product_id}}</td>
<td></td>
<td><input name="" v-model="order.quantity" class="form-control"></td>
<td><input name="" v-model="order.price" class="form-control" disabled></td>
<td><input name="" v-model="order.quantity * order.price" class="form-control" disabled></td>
<td></td>
</tr>
怎么做...?
【问题讨论】:
-
请完善您问题的详细信息,以便我们了解您想要达到的目标。如果您需要这方面的帮助,请查看这篇文章:How to Ask
-
请展示您尝试过的代码并解释它是如何不起作用的。我们无法解决未提出的问题。