title: I can't seed my database with Laravel factories
body: <p>I have the following relationships:</p>
  <p>A Flavor Brand has many Flavors and belongs to a brand</p>
  <pre><code>class FlavorBrand extends Model
  {
      public function brand()
      {
          return $this-&gt;belongsTo(FlavorBrand::class, 'brand_id');
      }
  
      public function ratings()
      {
          return $this-&gt;hasMany(FlavorRating::class, 'flavor_id');
      }
  }
  </code></pre>
  <p>A flavor belongs to a flavorBrand and has flavorRatings</p>
  <pre><code>class Flavor extends Model
  {
      public function brand()
      {
          return $this-&gt;belongsTo(FlavorBrand::class, 'brand_id');
      }
  
      public function ratings()
      {
          return $this-&gt;hasMany(FlavorRating::class, 'flavor_id');
      }
  }
  </code></pre>
  <p>A Flavor Rating belongs to a Flavor and belongs to a User</p>
  <pre><code>class FlavorRating extends Model
  {
      public function user()
      {
          return $this-&gt;belongsTo(User::class, 'user_id');
      }
  
      public function flavor()
      {
          return $this-&gt;belongsTo(Flavor::class, 'flavor_id');
      }
  
  }
  </code></pre>
  <p>When I try to create the relationships in the seeder like this:</p>
  <pre><code>public function run()
  {
      factory(\App\FlavorBrand::class, 20)-&gt;create()-&gt;each(function ($flavor_brand) {
          $flavor_brand-&gt;flavors()-&gt;saveMany(factory(\App\Flavor::class, 30)-&gt;make()-&gt;each(function ($flavor) {
              $flavor-&gt;ratings()-&gt;saveMany(factory(\App\FlavorRating::class, 200)-&gt;make()-&gt;each(function ($flavor_rating) use ($flavor) {
                  $flavor_rating-&gt;flavor()-&gt;associate($flavor)-&gt;save();
                  $flavor_rating-&gt;user()-&gt;associate(factory(\App\User::class)-&gt;create())-&gt;save();
              }));
          }));
      });
  }
  </code></pre>
  <p>I'm getting the following error, which makes no sense because I'm using the $flavor-&gt;ratings() relationship to add the ratings to a flavor, which should get the flavor_id from the flavor.</p>
  <pre><code>  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'flavor_id' cannot be null (SQL: insert into `flavor_ratings` (`comment`, `rating`, `active`, `flavor_id`, `updated_at`, `created_at`)
   values (Non rerum exercitationem officia ratione omnis. Perspiciatis placeat animi maxime sequi. Laudantium ut qui est ab facilis molestiae sint. Id aut distinctio animi magnam quia similique modi
  ., 3.2, 1, ?, 2020-06-29 14:12:10, 2020-06-29 14:12:10))
  
      
  PDOException::(&quot;SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'flavor_id' cannot be null&quot;)
  </code></pre>
  <p>There are the defined factories:</p>
  <pre><code>$factory-&gt;define(\App\FlavorBrand::class, function (Faker $faker) {
      return [
          'name' =&gt; $faker-&gt;name,
          'description' =&gt; $faker-&gt;text,
          'active' =&gt; 1,
      ];
  });
  
  $factory-&gt;define(\App\Flavor::class, function (Faker $faker) {
      return [
          'name' =&gt; $faker-&gt;name,
          'description' =&gt; $faker-&gt;text,
          'average_rating' =&gt; $faker-&gt;randomFloat(1, 1, 5),
          'active' =&gt; 1,
      ];
  });
  
  $factory-&gt;define(\App\FlavorRating::class, function (Faker $faker) {
      return [
          'comment' =&gt; $faker-&gt;text,
          'rating' =&gt; $faker-&gt;randomFloat(1, 1, 5),
          'active' =&gt; 1,
      ];
  });
  </code></pre>
  <p>Can anyone lend me a hand here? I've been blocked here for a few days, tried to get out by myself but I can't seem to make it work.</p>