title: how to compare two separate relations fields with each other in whereHas laravel?
body: <p>I use laravel 9 and I have 3 model here :</p>
  <p><strong>order</strong></p>
  <pre><code>city_id
  created_at
  updated_at
  </code></pre>
  <p><strong>shop</strong></p>
  <pre><code>city_id
  </code></pre>
  <p><strong>accepted_order</strong></p>
  <pre><code>shop_id
  order_id
  </code></pre>
  <p>notice : accepted_order is not pivot table</p>
  <pre><code>class order extends Model {
      public function accepted_orders(){
          return $this-&gt;HasMany(accepted_order::class);
      }
  }
  
  class shop extends Model {
      public function accepted_orders(){
          return $this-&gt;HasMany(accepted_order::class);
      }
  }
  
  class accepted_order extends Model {
      public function shop(){
          return $this-&gt;belongsTo(shop::class);
      }
      public function order(){
          return $this-&gt;belongsTo(order::class);
      }
  }
  </code></pre>
  <p>Now I want to get accepted_orders where :</p>
  <pre><code>order-&gt;updated_at &lt; 4 hour ago if order-&gt;city_id == shop-&gt;city_id
  </code></pre>
  <p>or</p>
  <pre><code>order-&gt;updated_at &lt; 2 days ago if order-&gt;city_id != shop-&gt;city_id
  </code></pre>
  <p>and both query orderBy created_at desc.</p>
  <p>how can I use whereHas query that compare two separate relations field with each other?</p>
  <p>thanks</p>