title: Laravel - Select just one row from pivot table and return data
body: <p>Currently, for a user, I can return all <code>matches</code> correctly.</p>
  
  <pre><code>public function getMatches()
  {
      $matches = Criteria::whereUserId( Auth::id() )
      -&gt;has('alerts')
      -&gt;with('alerts.location', 'alerts.user.companies')
      -&gt;get();
  
      $this-&gt;layout-&gt;content = View::make('users.alert.matches', 
          array('matches' =&gt; $matches));
  }
  </code></pre>
  
  <p><strong>Relationship:</strong></p>
  
  <p>A <code>Criteria</code> belongsToMany <code>Alerts</code> and an <code>Alert</code> belongsToMany <code>Criterias</code>.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>If the user wishes to see more information about a certain match, I want to <code>get</code> just that result from the database. On my view, I can access the <code>criteria_id</code> inside the first <code>forloop</code>, and the alert_id inside the second <code>forloop</code>.</p>
  
  <pre><code>@foreach($matches as $match)
      {{$match-&gt;id}}
          @foreach($match-&gt;alerts as $alert)
              {{$alert-&gt;id}}
          @endforeach
  @endforeach
  </code></pre>
  
  <p>But how can I use these variables to select just one pivot table match that the user wants to view more information about?</p>
  
  <p>If a user was to select a certain {{$alert->id}}, how do I find which criteria_id relates to that alert_id, and then query the database to return the just that row of information, both from the <code>criteria</code> table and <code>alert</code> table, along with the <code>with-&gt;</code> statement shown above.</p>
  
  <p>Many thanks for your help.</p>