Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public function myOrders(User $user)
  2. {
  3. $orders=Order::where('buyer_id',$user->id)->get();
  4. return view('myOrders', compact('user','orders'));
  5. //dd($orders);
  6. }
  7.  
  8. @foreach($orders as $sell)
  9. <tr>
  10. <td>{{$sell->orders}}</td>
  11. <td>{{$sell->products}}</td>
  12. <td>{{$sell->created_at}}</td>
  13. <td>{{$sell->order->shipping_name}}</td>
  14. <td>{{$sell->order->shipping_city}}</td>
  15. <td>{{$sell->order->shipping_phone}}</td>
  16. <td>
  17. <a href="">View Order Details</a>
  18. </td>
  19. </tr>
  20. @endforeach
  21.  
  22. public function orders()
  23. {
  24. return $this->hasManyThrough(Order::class, Products_model::class, 'buyer_id', 'seller_id', 'product_id');
  25. }
  26.  
  27. public function orderFromBuyers()
  28. {
  29. return $this->hasManyThrough(OrderProduct::class, Products_model::class, 'buyer_id', 'product_id');
  30. }
  31.  
  32. public function orderFromSellers()
  33. {
  34. return $this->hasManyThrough(OrderProduct::class, Products_model::class, 'seller_id', 'product_id');
  35. }
  36.  
  37. public function buyer()
  38. {
  39. return $this->belongsTo(User::class, 'id', 'buyer_id');
  40. }
  41.  
  42. public function seller()
  43. {
  44. return $this->belongsTo(User::class, 'id', 'seller_id');
  45. }
  46.  
  47. public function order()
  48. {
  49. return $this->belongsTo(Order::class);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement