title: LARAVEL: One-to-one relationship on a pivot table?
body: <p>I can't think of how to handle this in Eloquent. I have a many-to-many relationship that needs a one-to-one relationship assigned to it.</p>
  
  <p>Here is the basic database structure I designed in its simplest form:</p>
  
  <pre><code>ACCOUNTS: id
  
  AGENTS: id
  
  FEES: id
  
  ACCOUNT_AGENT: account_id, agent_id, fee_id
  </code></pre>
  
  <p>Each Account belongsToMany Agents.</p>
  
  <p>Each Agent belongsToMany Accounts.</p>
  
  <p>Each "Account_Agent" (the many-to-many pivot table) belongsTo Fee.</p>
  
  <p>How do I define that third relationship in an Eloquent model?</p>
  
  <p>I want to be able to access the "account_agent" fee like this (or similar):</p>
  
  <pre><code>$account = Account::first();
  
  foreach ($account-&gt;agents as $agent) {
    echo $agent-&gt;fee;
  }
  </code></pre>
  
  <p>Thanks, hopefully my question is clear.</p>