title: Laravel hasMany relation with custom query
body: <p>I have a table for <code>Product Orders</code>. An order belongs to a <code>Customer</code> (Buyer) whose id is in the order record. I can get customer orders with default <code>hasMany</code> relation</p>
  
  <pre><code>// Customer model
  public function orders() {
    return $this-&gt;hasMany(Order::class);
  }
  </code></pre>
  
  <p>In the other hand, as each <code>Product</code> belongs to a <code>Customer</code> (different from the one whose id is in the order) <code>Customer</code> (Seller), I want the other <code>Customer</code> can see the list of <code>Order</code>s which have his <code>Product</code> in it. </p>
  
  <p>I want to get list of customer <code>Order</code>s when either he is the seller or the buyer. I want to create a custom relation or modify a relation to achieve the result.</p>
  
  <p>Is it possible to achieve this with Laravel's relations? </p>
  
  <p>Customers table:</p>
  
  <pre><code>---------------------------
  | customer_id |   name    | 
  ---------------------------
  | 1           | seller    |
  | 2           | buyer     |
  </code></pre>
  
  <p>Products table:</p>
  
  <pre><code>---------------------------------------
  | product_id  |   name    | seller_id |
  ---------------------------------------
  | 101         | iPhone 6s |   1       |
  </code></pre>
  
  <p>Orders Table</p>
  
  <pre><code>----------------------------------------
  | order_id  | customer_id | product_id |
  ----------------------------------------
  | 500       | 2           |   101      |
  </code></pre>
  
  <p>When using simple <code>hasMany</code> relation, buyer will see order 500 in his orders list. </p>
  
  <pre><code>$buyer-&gt;orders();
  </code></pre>
  
  <p>I want to create a single relation that when I call it from seller's side, he can see order 500 in his orders list.</p>
  
  <pre><code>$seller-&gt;orders();
  </code></pre>