title: laravel faker duplicate data
body: <p>I have a Laravel table for <code>hits</code>. I want to generate a lot of test data to test some charts based on the hit location, so I created a factory like this:</p>
  
  <pre><code>&lt;?php
  
  use Carbon\Carbon;
  use Faker\Generator as Faker;
  
  $factory-&gt;define(App\Hit::class, function (Faker $faker) {
      $date = Carbon::parse($faker-&gt;dateTimeBetween("-2 months", "now")-&gt;format('Y-m-d'));
      $faker-&gt;seed(rand());
  
      return [
          'latitude' =&gt; '',
          'longitude' =&gt; '',
          'country' =&gt; 'US',
          'state' =&gt; '',
          'city' =&gt; '',
          'created_at' =&gt; $date,
          'updated_at' =&gt; $date,
      ];
  });
  </code></pre>
  
  <p>Then in the <code>HitsTableSeeder</code> it does this:</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Seeder;
  
  class HitsTableSeeder extends Seeder
  {
      /**
       * Run the database seeds.
       *
       * @return void
       */
      public function run()
      {
          $i = 0;
  
          while ($i &lt;= 25000) {
              factory(App\Hit::class)-&gt;create(
                  [
                      'latitude' =&gt; $faker-&gt;latitude,
                      'longitude' =&gt; $faker-&gt;longitude,
                      'country' =&gt; 'US',
                      'state' =&gt; $faker-&gt;state,
                      'city' =&gt; $faker-&gt;city,
                  ]
              );
              $i++;
          }
      }
  }
  </code></pre>
  
  <p>It always returns the same data:</p>
  
  <pre><code>-[ RECORD 1 ]------+---------------------------
  id                 | 1
  latitude           | 41.31
  longitude          | -72.92
  country            | US
  state              | CT
  city               | New Haven
  -[ RECORD 2 ]------+---------------------------
  id                 | 2
  latitude           | 41.31
  longitude          | -72.92
  country            | US
  state              | CT
  city               | New Haven
  -[ RECORD 3 ]------+---------------------------
  id                 | 3
  latitude           | 41.31
  longitude          | -72.92
  country            | US
  state              | CT
  city               | New Haven
  </code></pre>
  
  <p>This happens regardless of whether I try to override the factory's values in the table seeder or write the data directly in the factory and <em>don't</em> try to override the value in the seeder.</p>
  
  <p>How can I get truly random data?</p>
  
  <p>NOTE: I'm accepting @Erick Patrick's answer because he's correct, but the method I had been using is correct as well. The issue turned out to be that the <code>Hit</code> model had an <a href="https://laravel.com/docs/5.7/eloquent#events" rel="nofollow noreferrer">event</a> attached to geocode the hit before saving it-- and for some reason the geocoder always returned this same location for the faked data, presumably because it couldn't be found!</p>