title: Count two rows with scopes and relationships (Laravel)
body: <p>So I have two tables, one called <code>members</code> and one called <code>memberships</code></p>
  
  <p>My goal is to count the number of members who have a certain membership. I've set up foreign keys and relationships are working fine, to the point where I need to do the counts.</p>
  
  <p>My scope is (in <code>Member</code> model)</p>
  
  <pre><code>public function scopeActive($query) {
      return $query-&gt;where('membership_ended_at', Null);
  }
  </code></pre>
  
  <p>My relationship is (in <code>Member</code> model)</p>
  
  <pre><code>public function membership() {
      return $this-&gt;belongsTo('App\Membership');
  }
  </code></pre>
  
  <p>This query works fine, and I see how many members who are <code>active()</code> that has the <code>membership_id</code> of 6.</p>
  
  <pre><code>$members_student = Membership::find(6)-&gt;members()-&gt;active()-&gt;count();
  </code></pre>
  
  <p>I don't know if that's supposed to work, but it does. Now, the issue I have is that we have a regular student membership, and a student abroad membership with the ID of 14.</p>
  
  <p>I assumed maybe this would work, but I quickly realized I was wrong</p>
  
  <pre><code>$members_student = Membership::find([6,14])-&gt;members()-&gt;active()-&gt;count();
  </code></pre>
  
  <p>I know I can call two queries and just add the two together, but I'm looking for a more elegant solution. Something that only required one query, and will half my queries.</p>
  
  <p>Hopefully someone else has seen this before</p>