title: Generate statistics in Laravel
body: <p>I am beginner in Laravel. I use in my project Laravel 5.8.</p>
  
  <p>I have schema:</p>
  
  <pre><code>Schema::create('statistics', function (Blueprint $table) {
      $table-&gt;bigIncrements('id');
      $table-&gt;bigInteger('company_id')-&gt;unsigned();
      $table-&gt;foreign('company_id')-&gt;references('id')-&gt;on('companies')-&gt;onDelete('cascade');
      $table-&gt;text('agent')-&gt;nullable();
      $table-&gt;date('date')-&gt;nullable();
      $table-&gt;ipAddress('ip');
      $table-&gt;bigInteger('user_id')-&gt;default(0);
      $table-&gt;bigInteger('quest_id')-&gt;default(0);
      $table-&gt;string('browser', 70)-&gt;nullable();
      $table-&gt;string('platform', 70)-&gt;nullable();
      $table-&gt;string('language', 12)-&gt;nullable();
      $table-&gt;engine = "InnoDB";
      $table-&gt;charset = 'utf8mb4';
      $table-&gt;collation = 'utf8mb4_unicode_ci';
  });
  </code></pre>
  
  <p>I get statistics from this function:</p>
  
  <pre><code>public function generateStatistics(string $dateFrom, string $dateTo, int $id)
  {
      return Statistics::whereBetween('date', [$dateFrom, $dateTo])-&gt;where('user_id', $id)-&gt;get();
  }
  
  $statisticsTotal = $this-&gt;frontendRepository-&gt;generateStatistics($dateFrom, $dateTo, $request-&gt;user()-&gt;id);
  $statisticsResultsTotal = [];
  
  $period = CarbonPeriod::create($dateFromInput, '1 day', $dateToInput);
  foreach ($period as $dt) {
      $date = $dt-&gt;format("Y-m-d");
      $count = 0;
      $count2 = 0;
      foreach ($statisticsTotal as $stat){
          if ($stat-&gt;date == $date){
              $count = $count + 1;
          }
      }
      array_push($statisticsResultsTotal, "$date|$count");
  };
  </code></pre>
  
  <p>This code generate statistics. It's work fine.
  Now I need generate unique visit statistics
  Unique = unique IP.</p>
  
  <p>How can I make it?</p>