Can you help me again? I have 3 tables
Product Table
id
product_name
Productquantity Table
id
item_id
price
Orders
id
req_id
quantity_id
quantity
amount
How can I get the product name in my CartView? I only have this in my code
Order Model
public function product()
{
return $this->belongsTO('App\Productquantity', 'item_id', 'id');
}
My Controller
$dataReqorder = Reqorder::where('req_id','=', $shoppingId)->with('product')->get();
My View
@foreach($dataReqorder as $order)
<tr class="item{{$order->id}}">
<td> <a href="products/{{$order->id}}" class="name">{{$order->product->prod_id}}</a> </td>
<td>{{$order->amount}}</td>
<td>{{$order->quantity}}</td>
</tr>
@endforeach
I want this {{$order->product->prod_id}} should be the name of the product instead of the product ID.. I just do not know how to do it on model and controller.. Please help
I think you need to reorder some things
For more info I recommend you to see the documentation
https://laravel.com/docs/5.6/eloquent-relationships#many-to-many