title: How to count rows of database and show it at laravel 5.4 view?
body: <p>I'm new at laravel. I'm working on new web application using laravel 5.4. I want to count the number of data in a database and show the result in view. So, I have used this code in controller:</p>
  
  <pre><code>public function bending_img(){
      $counts = requestImg::where('is_done', '=', '0')-&gt;count();
      return view('/dashboard')-&gt;with(['counts'=&gt; $counts]);
  }
  
  public function uploaded_img(){
      $count = requestImg::where('is_done', '=', '1')-&gt;count();
      return view('/dashboard')-&gt;with(['count'=&gt; $count]);
  }
  </code></pre>
  
  <p>and in view:</p>
  
  <pre><code>@if(count($counts)== 0)
           no call record to be viewed
  @else
           &lt;div class="huge"&gt;{{$counts}}&lt;/div&gt;
  @endif
  
  @if(count($count)==0)
           no call record to be viewed
  @else
           &lt;div class="huge"&gt;{{$count}}&lt;/div&gt;
  @endif
  </code></pre>
  
  <p>but there is an error: <code>undefined variable</code>.</p>
  
  <p>Please resolve this error.  </p>