title: How to use condition for one to many relationship in Laravel
body: <p>I am using Laravel 4.2</p>
  
  <p>I have the following models:
  <strong>User</strong> and <strong>Booking</strong> (booking has user_id that references User model in id)</p>
  
  <p>I want to make a query to retrieve Bookings where bookings.starts_at > now</p>
  
  <p>I want something like this:</p>
  
  <pre><code>User::with('bookings')-&gt;where('starts_at' , '&gt;' time())-&gt;get();
  </code></pre>
  
  <p>but where condition is applied on User and hence it causes an exception because User does not have starts_at.</p>
  
  <p>How to solve this issue while still using Eloquent class?</p>
  
  <p>Thanks</p>