Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function myOrders(User $user)
- {
- $orders=Order::where('buyer_id',$user->id)->get();
- return view('myOrders', compact('user','orders'));
- //dd($orders);
- }
- @foreach($orders as $sell)
- <tr>
- <td>{{$sell->orders}}</td>
- <td>{{$sell->products}}</td>
- <td>{{$sell->created_at}}</td>
- <td>{{$sell->order->shipping_name}}</td>
- <td>{{$sell->order->shipping_city}}</td>
- <td>{{$sell->order->shipping_phone}}</td>
- <td>
- <a href="">View Order Details</a>
- </td>
- </tr>
- @endforeach
- public function orders()
- {
- return $this->hasManyThrough(Order::class, Products_model::class, 'buyer_id', 'seller_id', 'product_id');
- }
- public function orderFromBuyers()
- {
- return $this->hasManyThrough(OrderProduct::class, Products_model::class, 'buyer_id', 'product_id');
- }
- public function orderFromSellers()
- {
- return $this->hasManyThrough(OrderProduct::class, Products_model::class, 'seller_id', 'product_id');
- }
- public function buyer()
- {
- return $this->belongsTo(User::class, 'id', 'buyer_id');
- }
- public function seller()
- {
- return $this->belongsTo(User::class, 'id', 'seller_id');
- }
- public function order()
- {
- return $this->belongsTo(Order::class);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement