title: Laravel Eloquent relationship for user to friends
body: <p>I am confused with eloquent relationships. I have two tables:</p>
  
  <pre><code>USERS:
  id, name, pwd, etc...
  
  FRIENDS:
  id, user_id, friend_id
  </code></pre>
  
  <p>For the FRIENDS table, I have two foreign keys:</p>
  
  <pre><code>$t-&gt;foreign('user_id')
    -&gt;references('id')
    -&gt;on('users');
  
  $t-&gt;foreign('friend_id')
    -&gt;references('id')
    -&gt;on('users');
  </code></pre>
  
  <p>In each class I have the following relationships:</p>
  
  <p>USER class:</p>
  
  <pre><code>/**
   * A user can have many friends
   */
  public function friends()
  {
      return $this-&gt;hasMany(User::class, 'friend_id', 'id');
  }
  </code></pre>
  
  <p>FRIEND class:</p>
  
  <pre><code>/**
   * A friend can belong to a user
   */
  public function friend()
  {
      return $this-&gt;belongsTo(User::class, 'id', 'user_id');
  }
  
  /**
   * A user friends are connected to
   */
  public function user()
  {
      return $this-&gt;belongsTo(User::class, 'id', 'friend_id');
  }
  </code></pre>
  
  <p>I want to end up with </p>
  
  <pre><code>Auth::user()-&gt;friends()-&gt;get();
  </code></pre>
  
  <p>Should the relationship be a <code>hasManyThrough()</code>? How do I implement this when the USERS table is self referenced via the FRIENDS table?</p>