我正在尝试覆盖 voyager-admin 的视图并对其进行编辑,但出现“未定义变量:产品”错误,我不知道为什么。这是我的 OrdersController:$order = Orders::find($id);$products = $order->products;return Voyager::view($view, compact('dataType', 'dataTypeContent', 'isModelTranslatable','order', 'products'))这是我的观点:<ul> @foreach ($products as $product) <li style="margin-bottom: 10px"> <div>ID Produs: {{$product->id}}</div> <div>Nume Produs: {{$product->name}}</div> <div>Pret Produs: {{$product->presentPrice()}}</div> <div>Cantitate: {{$product->pivot->quantity}}</div> </li> @endforeach </ul>如果还需要什么,请让我知道,我就是不明白为什么要给我这个错误。我的订单模型 public function products(){ return $this->belongsToMany('App\Product')->withPivot('quantity');}我的产品型号 public function orders(){ return $this->belongsToMany('App\Orders');}
2 回答
- 2 回答
- 0 关注
- 147 浏览
添加回答
举报
0/150
提交
取消