title: Eloquent "whereDate" not working after Laravel 5.4 Upgrade
body: <p>(sorry in advance for the long post)</p>
  
  <p>I am in the process of upgrading my application from laravel 5.2 to 5.4, and have been stuck on this problem since this morning. For some reason my query to select upcoming business events with the Eloquent 'whereDate' is not returning anything, even though everything else points to the fact that it should be working!</p>
  
  <p>I have a phpUnit test that won't pass to try and localize the problem. (See further below)</p>
  
  <p>I have a '<strong>Business</strong>' model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Business extends Model
  {
      protected $table = 'businesses';
      ..
  
  public function businessEvents(){
      return $this-&gt;hasMany('App\BusinessEvent', 'business_id');
  }
  </code></pre>
  
  <p>As well as a '<strong>BusinessEvent</strong>' model:</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class BusinessEvent extends Model
  {
    protected $table = 'business_events';
    protected $fillable = ['business_id', ..., 'start_date', 'end_date'];
  
    public function business(){
        return $this-&gt;belongsTo('App\Business', 'business_id');
    }
  ...
  </code></pre>
  
  <p>Both of which I make dummy versions of in my test. The dummy 'business' works for other tests, but I introduced the following <strong>dummy 'business_event'</strong> for this test case:</p>
  
  <pre><code>protected function createMockBusinessEventWithUpcomingDateTime($businessId){
    $faker = Faker::create();
  
    $businessEvent = BusinessEvent::create([
        'business_id'   =&gt; $businessId,
        'name'          =&gt; $faker-&gt;name,
        'description'   =&gt; $faker-&gt;text,
        'start_date'    =&gt; date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")."+30 minutes")),
        'end_date'      =&gt; date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")."+1 hour +30 minutes"))
    ]);
  
    ...
  
    $business = Business::find($businessId);
    if($business){
      $businessEvent-&gt;business()-&gt;associate($business);
    }
  
    return $businessEvent;
  }
  </code></pre>
  
  <p>Now here is the actual <strong>test</strong> function:</p>
  
  <pre><code>public function testGetUpcomingN(){
  
      $this-&gt;businessEvent  = $this-&gt;createMockBusinessEventWithUpcomingDateTime($this-&gt;business-&gt;id);
  
      $response = $this-&gt;json('GET', '/api/v1/business/'.$this-&gt;business-&gt;id.'/events/upcoming/2');
  
      $this-&gt;outp($response-&gt;content());
  
      $this-&gt;outp("Testing Assertions");
      $this-&gt;assertEquals(200, $response-&gt;status());  
      $this-&gt;assertEquals($this-&gt;business-&gt;businessEvents()-&gt;first()-&gt;id, $this-&gt;businessEvent-&gt;id);     
  }
  </code></pre>
  
  <p>The test doesn't fail, which means that the event is correctly being associated with the business, and no matter how I query the api endpoint (HttpRequester, Logging result, returned value in test, production...) it always returns an empty array!</p>
  
  <p>The <strong>following function is what is called</strong> in the controller (also verified!): </p>
  
  <pre><code>public function upcomingN($businessId, $n){
      Log::info('Get upcoming '.$n.' recorded events for business with id: '.$businessId);
      $business = Business::find($businessId);
      if (is_null($business)){
          Log::warning('No business exists with given id. Exiting.');
          return response('No Content.', 204);
      }
  
      $currentDate = date('Y-m-d H:i:s');
  
      $greaterThan = $business-&gt;businessEvents()-&gt;first()-&gt;end_date &gt;= $currentDate;
      Log::info("Greater THAN:", [$greaterThan]);
  
      $events = $business-&gt;businessEvents()-&gt;whereDate('end_date', '&gt;=', $currentDate)-&gt;take($n)-&gt;get();
  
      if (!is_null($events)){
          Log::info('Got upcoming N recorded events for business with id: '.$businessId, (array) $events);
          return response()-&gt;json($events);
      }
  
      return response('No Content.', 204);
  }
  </code></pre>
  
  <p>As you can see, I even tried logging the "$greaterThan" boolean that should test the exact same thing that "whereDate" does, and it evaluates to true! I have tried Carbon::parse()-ing, setting the locale, and now I am pretty much out of ideas.</p>
  
  <p>The <strong>old function</strong> that worked in 5.2:</p>
  
  <pre><code>public function upcomingN($businessId, $n){
     Log::info('Get upcoming N recorded events for business with id: '.$businessId);
  $business = Business::find($businessId);
  if (is_null($business)){
      Log::warning('No business exists with given id. Exiting.');
          return response('No Content.', 204);
      }
  
      $currentDate = date('Y-m-d H:i:s');
      $events = $business-&gt;businessEvents()-&gt;whereDate('start_date', '&gt;=', $currentDate)-&gt;take($n)-&gt;get();
  
       if (!is_null($events)){
           Log::info('Got upcoming N recorded events for business with id: '.$businessId, (array) $events);
           return response()-&gt;json($events);
       }
  
      return response('No Content.', 204);
  }
  </code></pre>
  
  <p>One thing I did have to change during the upgrade was setting the mysql-db to non-strict, because Laravel was complaining about a lack of default values. However, I've checked the db and the test entries are correctly populated.</p>
  
  <p>Any help would be greatly appreciated! </p>