title: Why does the foreign key in a hasOne relationship need to be in the referenced table?
body: <p>Why does Laravel’s Eloquent insist that the foreign key in a hasOne relationship must be in the referenced table and not in the parent table?</p>
  
  <p>I'm asking for general understanding / enrichment.</p>
  
  <p>eg, from the Laravel docs: If a <code>User</code> has one <code>Phone</code>, the <code>Phone</code> model is expected to have a <code>user_id</code> foreign key.</p>
  
  <p>This seems like more work for the database to do: to go and find the <code>user_id</code> in the <code>Phones</code> table, versus a <code>phone_id</code> already being present on the <code>User</code> model.</p>
  
  <p>I'm assuming these three reasons below all apply - <strong>are there any other reasons to structure it in this way?</strong></p>
  
  <ul>
  <li>It can utilise logic already written for looking up has-many relationships (where it’s obvious why it needs to be this way).</li>
  <li>The relationship can easily be ‘migrated’ to a has-many relationship.</li>
  <li>It guarantees that wherever a relationship exists, the <code>Phone</code> model also does in fact exist. (Otherwise, a <code>phone_id</code> in the <code>User</code> model could potentially point to a non-existent entry in the <code>Phones</code> table.)</li>
  </ul>