title: count() "where" statement in Laravel blade?
body: <p>I am interested in displaying quick counts of email stats in my application, but I'm getting hung up on finding an efficient way to generate the counts. I am hoping to just use the eloquent relationship with some sort of "count where" statement inside of blade.</p>
  
  <p>Getting the total count works as it should: </p>
  
  <pre><code>{{count($emails-&gt;mandrillemails)}}
  </code></pre>
  
  <p>but is something like this possible?: </p>
  
  <pre><code>{{count($emails-&gt;mandrillemails-&gt;msg_state == 'bounced')}}
  {{count($emails-&gt;mandrillemails-&gt;msg_state == 'open')}}
  </code></pre>
  
  <p>Here is my block of code with the @if and @foreach statements:</p>
  
  <pre><code>     @if(count($sentEmails) &gt; 0)
        @foreach ($sentEmails as $emails)
         &lt;tr&gt;
          &lt;td&gt;
            @if(count($emails-&gt;mandrillemails) &gt; 0)
               &lt;p&gt;&lt;span class="badge"&gt;&lt;i class="fa fa-paper-plane"&gt;&lt;/i&gt; {{count($emails-&gt;mandrillemails)}}&lt;/span&gt; &lt;span class="badge"&gt;&lt;i class="fa fa-exclamation-triangle"&gt;&lt;/i&gt; {{count($emails-&gt;mandrillemails-&gt;msg_state == 'bounced')}}&lt;/span&gt;&lt;/p&gt;
            @endif
          &lt;/td&gt;
        &lt;/tr&gt;
  </code></pre>
  
  <p>When I attempt this, I get an undefined property error on "msg_state"</p>