title: Laravel Eloquent find for composite key
body: <p>I've recently started working with Laravel 5 as a framework. So far everything's been completely straight-forward and it's just great to work with it. Currently however I'm running into some troubles regarding on of my Eloquent models.</p>
  
  <p>The database table <code>reports</code> has the following schema:</p>
  
  <pre><code>| id | group_id | score | ... |
  </code></pre>
  
  <p><code>group_id</code> is a foreign key referencing the <code>groups</code> table. The primary key of this table is a composite of <code>id</code> and <code>group_id</code>. <code>id</code> is also not auto-increasing, as it's an external id I'm using for easier internal processing.</p>
  
  <p>Each external id can be present for every of my groups once and have a different score for each of them, hence the composite primary key.</p>
  
  <p>When visiting one of my pages, I want to fetch the latest records from my external data source and match them with the corresponding database rows. If they don't exist, I want to create them.</p>
  
  <p>My current code for this route is:</p>
  
  <pre><code>public function showReports ($id)
  {
     $group = Group::findOrFail($id);
  
     foreach ($group-&gt;getLatestReports(20) as $reportElement)
     {
         $report = Report::find($reportElement['id']);
         if (is_null($report))
         {
             $report = new Report;
             // Fill values ...
             $report-&gt;save();
         }
     }
  }
  </code></pre>
  
  <p>This obviously doesn't work as anticipated, as it only looks for the <code>id</code><br>
  ( <code>::find($reportElement['id'])</code> ), not for the <code>group_id</code>. As usual with my questions, the answer is probably super easy, yet I can't seem to find it right now.</p>