title: Counting a many to many relationship?
body: <p>I have a many to many relationship between users and images.</p>
  
  <p>User Model</p>
  
  <pre><code>public function image()
  {
      return $this-&gt;belongsToMany('\App\Image');
  }
  </code></pre>
  
  <p>Image Model</p>
  
  <pre><code>public function user()
  {
      return $this-&gt;belongsToMany('\App\User');
  }
  </code></pre>
  
  <p>Tables</p>
  
  <p>users</p>
  
  <pre><code>id | name
  </code></pre>
  
  <p>images</p>
  
  <pre><code>id | url
  </code></pre>
  
  <p>image_user</p>
  
  <pre><code>id | image_id | user_id
  </code></pre>
  
  <p>When a user 'favourites' an image, it's stored in the pivot table.</p>
  
  <pre><code>id | image_id | user_id
   1      1          1
   2      2          1
   3      1          2
  </code></pre>
  
  <p>I need a count of each images favourites.</p>
  
  <p>I try something like:</p>
  
  <pre><code> Image::with('user')-&gt;find(1)-&gt;count();
  </code></pre>
  
  <p>But this counts the number of users, not the number of favourites.</p>
  
  <p>Ideally I would like to return all of the image data along with a count of the user data - how can I do this?</p>