title: Laravel Eloquent "Many-to-Many-to-One ?"
body: <p>My database schema:</p>
  
  <pre><code>user:
      - id
      - email
      ...
  
  notification_user:
      - user_id
      - notification_id
  
  notifications:
      - id
      - channel_id
      - message
      ...
  
  channels:
      - id
      - name
      ...
  </code></pre>
  
  <p><br />User Model:</p>
  
  <pre><code>public function notifications()
  {
      return $this-&gt;belongsToMany('App\Notification');
  }
  </code></pre>
  
  <p><br />Notification Model:</p>
  
  <pre><code>public function users()
  {
      return $this-&gt;belongsToMany('App\User');
  }
  </code></pre>
  
  <p><br />
  <strong>What is the problem:</strong>
  <code>App\User::find(1)-&gt;notifications</code> shows all notifications which belongs to this user and it works fine, but I also need to include data from <code>channels</code> table.</p>
  
  <pre><code>&lt;App\Notification #000000004e6906c1000000014ed0d97c&gt; {
     id: 20,
     channel_id: 3,
     message: "...",
     created_at: "2015-05-31 17:37:12",
     updated_at: "2015-06-07 10:37:12",
     pivot: &lt;Illuminate\Database\Eloquent\Relations\Pivot #000000004e690718000000014ed0d97c&gt; {
         user_id: 1,
         notification_id: 20
     }
  },
  </code></pre>
  
  <p>The above is output from tinker. <strong>Question is:</strong> How to include data from <code>channels</code> table for every notification.</p>