title: Laravel factories return value (in afterCreating hook)
body: <p>I am creating a factory and using the "afterCreating" hook to insert some relationships.</p>
  
  <p>This is the code:</p>
  
  <pre><code>$factory-&gt;define(MyModel::class, function (Faker $faker) {
      return [
          'name'                          =&gt; $faker-&gt;name
      ];
  });
  
  $factory-&gt;afterCreating(MyModel::class, function ($my_model, $faker) {
  
      // Make changes to my model, add relationships to it
  
      return $my_model; // or return "test"
  });
  </code></pre>
  
  <p>My question is how to I return the modified model, the one modified in afterCreating()? Is it even possible to do so?</p>
  
  <p>What I get returned is the original model that was created in the first method. The <a href="https://laravel.com/api/5.6/Illuminate/Database/Eloquent/Factory.html" rel="nofollow noreferrer">Laravel Documentation API</a> states that it returns $this, which tells me it's the instance of the afterCreating, but it doesn't.</p>
  
  <p>Thank you!</p>