title: NULL Results in Array from Eloquent Query
body: <p>Does anyone have any idea why this query would be producing some NULL results (array):</p>
  
  <pre><code>$events = $this-&gt;event
      -&gt;with('delegates', 'course')
      -&gt;where('start_date', '&lt;=', $today)
      -&gt;where('active', '1')
      -&gt;where('event_status_id', '!=', '3')
      -&gt;hasCosts()
      -&gt;has('delegates')
      -&gt;get()
      -&gt;map(function($event) {
          foreach ($delegates = $event-&gt;delegates()-&gt;has('contact')-&gt;get() as $delegate) {
              $account = $delegate-&gt;contact-&gt;account;
  
              return [
                  'company' =&gt; $account-&gt;company_name,
                  'income' =&gt; $account-&gt;income($delegates),
                  'profit' =&gt; $account-&gt;profit($event, $delegates),
                  'event' =&gt; $account-&gt;eventDetails($event, $delegates)
              ];
          }
      })
      -&gt;toArray();
  </code></pre>
  
  <p>I've stepped into the 'foreach' loop and dumped the id's for each event, account, contact, and delegate and there are no NULL results there. I also receive no errors.</p>
  
  <p>When I dump the $events variable I receive output like:</p>
  
  <pre><code>array(8) {
      [0] NULL
      [1] array(4) {
          ["company"] "Razorfish"
          ["income"] 523
          ["profit"] "69.29"
          ["event"] "ITIL® Service Transition Apr 7, 2014 in London (141)"
      }
      [2] array(4) {
          ["company"] "European Central Bank - Europa ECB"
          ["income"] 1332
          ["profit"] "137.33"
          ["event"] "ITIL® Service Offerings &amp; Agreements Apr 7, 2014 in London (142)"
      }
      [3] array(4) {
          ["company"] "Knowledge Pool - KP delegates"
          ["income"] 475
          ["profit"] "-111.75"
          ["event"] "ITIL® Foundation Apr 7, 2014 in Leeds (143)"
      }
      [4] array(4) {
          ["company"] "Plan International/ Plan UK"
          ["income"] 537
          ["profit"] "118.43"
          ["event"] "ITIL® Foundation Apr 14, 2014 in London (144)"
      }
      [5] array(4) {
          ["company"] "Cell Therapy Catapult ( part of Guy's hospital)"
          ["income"] 550
          ["profit"] "-114.75"
          ["event"] "ITIL® Service Design Apr 14, 2014 in London (145)"
      }
      [6] array(4) {
          ["company"] "European Central Bank - Europa ECB"
          ["income"] 597
          ["profit"] "69.80"
          ["event"] "BCS Specialist Certificate in Supplier Management Apr 14, 2014 in London (146)"
      }
      [7] array(4) {
          ["company"] "C Hoare &amp; Co (hoares bank)"
          ["income"] 523
          ["profit"] "97.71"
          ["event"] "ITIL® Continual Service Improvement Apr 23, 2014 in London (148)"
      }
  }
  </code></pre>
  
  <p>Notice the first NULL result. This is just a sample of the output, but there are numerous results like this in the real output.</p>
  
  <p>For brevity the hasCosts() method in the initial query is a query scope function:</p>
  
  <pre><code>public function scopeHasCosts($query)
  {
      return $query-&gt;where('tutor_cost', '&gt;', 0)
          -&gt;orWhere('exam_cost', '&gt;', 0)
          -&gt;orWhere('material_cost', '&gt;', 0)
          -&gt;orWhere('venue_cost', '&gt;', 0)
          -&gt;orWhere('notional_cost', '&gt;', 0)
          -&gt;orWhere('buy_price', '&gt;', 0);
  }
  </code></pre>