title: Get object only when relation counts result is more then 0 [laravel]
body: <p>I have a problem with get data only when relation query count is more than 0.</p>
  
  <p>This is my model of <strong>customer</strong> with relation</p>
  
  <pre><code>class Customer extends Model
  {
      protected $table = 'customers';
  
      public function contracts()
      {
          return $this-&gt;hasMany('App\Contract');
      }
  </code></pre>
  
  <p>This is my model of <strong>contracts</strong></p>
  
  <pre><code>class Contract extends Model
  {
      public function customer()
      {
          return $this-&gt;belongsTo('App\Customer');
      }
  }
  </code></pre>
  
  <p>On the end i need only customers who they contracts beetwen some date</p>
  
  <pre><code>$customers = Customer::with(['contracts' =&gt; function($query)
       {
          $query-&gt;where('data_end','&gt;=','2017-07-01')
                -&gt;where('data_end','&lt;=','2017-07-31') 
                -&gt;where('typ','=','U') ;
       }
      ])-&gt;paginate(10);
  </code></pre>
  
  <p>But i have all customers. and it looks like this:</p>
  
  <pre><code>"Customer 1"
  "Customer 2"
  "Customer 3"
    *"Contract 1"
    *"Contract 2"
    *"Contract 3"
  "Customer 4"
    *"Contract 1"
    *"Contract 2"
    *"Contract 3"  
  "Customer 4"  
  </code></pre>
  
  <p>In this example i don't need customer 1,2, and 5. How can i do it with eager loading and object with relation on the end.</p>
  
  <p><a href="https://i.stack.imgur.com/9xwau.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>This is happen, i dont need customer with X on the screenshot - I mean, I don't need customer with 0 contracts from where query</p>