title: Get an averange of visitors in Laravel
body: <p>I want to have an averange of visitors per day. I'm using Laravel 4.</p>
  
  <p>The database structure I have is this:</p>
  
  <blockquote>
    <p>Name: <code>visitor</code></p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/yHSCZ.png" alt="Structure"></p>
  
  <p>Now I tried to use the avg() function of Laravel, but I can't find a right solution. Could someone help me please with this?</p>
  
  <p>I already have an controller wich one looks like this:</p>
  
  <pre><code>public function index()
      {
  
          //$select_stats = Visitor::where('visit_date', '&gt;=', Carbon::now()-&gt;startOfMonth())-&gt;get();
  
          $begin = date('Y-m-01');
          $end = date('Y-m-t');
  
          $visits = Tracker::selectRaw('date, count(ip)')-&gt;groupBy('date')-&gt;whereRaw("date between '$begin' and '$end'")-&gt;get();
  
          //get total visits per month
          $get_visits = Visitor::whereRaw("date between '$begin' and '$end'")-&gt;count();
  
          //get averange visits
  
  
          return View::make('admin.home.index')-&gt;with('stats', $visits)-&gt;with('get_visits', $get_visits)/*-&gt;with('get_avg_visits', $get_avg_visits)*/;
  
      }
  </code></pre>