title: Fetch invoices by user id in Eloquent ORM
body: <p>I want to fetch all invoices a user has raised using the Eloquent ORM.</p>
  
  <p>At the moment, I'm fetching the <code>invoice.id</code> from a join table UsersInvoices by the <code>user.id</code> and then looping through and fetching the invoices from the Invoices table based on the id.</p>
  
  <pre><code>$user = Sentry::getUser();
  $invoiceIDs = UsersInvoice::where('user_id', '=', $user-&gt;id)-&gt;get()-&gt;toArray();
  $invoices = array();
  
  foreach ($invoiceIDs as $key =&gt; $row) {
      array_push($invoices, Invoice::find($row['invoice_id']));
  }
  
  
  
  $this-&gt;data['title'] = 'Invoices';
  $this-&gt;data['invoices'] = $invoices;
  
  
  /** render the template */
  App::render('@invoices/pending/index.twig', $this-&gt;data);
  </code></pre>
  
  <p>But I think this could/should be handled by the ORM by modelling the relationship between user and invoices.</p>
  
  <p>It looks as though I should be able to manage this <a href="http://laravel.com/docs/eloquent#one-to-many" rel="nofollow">like so</a> by simply posting the <code>user.id</code> into the invoices table as a foreign key - Maybe I don't need a join table as there is nothing that is unique to the relationship that needs to be stored... ?</p>