title: Pass parent id to relationship factory?
body: <p>I have a factory of <code>posts</code> and a factory of <code>posts_images</code>, a post can have many images, I did create a seeder for posts that look like this.</p>
  
  <pre><code>$posts = factory(App\Models\Post::class, 100)-&gt;create()
  -&gt;each(function($post) {
      $post-&gt;images()-&gt;saveMany(factory(App\Models\PostsImage::class, 3)-&gt;make());
  });
  </code></pre>
  
  <p>I want to create <code>100 posts</code> and that each post have <code>3 images</code>, this kind of work, the problem is when the image is created</p>
  
  <p>I want the image to be created from a base_64 string and saved in certain directory but I need the <code>id</code> of the <code>post</code> so I can create the folder where it will be created.</p>
  
  <pre><code>$factory-&gt;define(App\Models\PostsImage::class, function (Faker $faker) {
      //this does not get me the id
      $id = factory(\App\Models\Post::class)-&gt;make()-&gt;id;
      $name      = time();
      $b64_image = \Config::get('constants.seed_image');
      $data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $b64_image));
      if(!file_exists(public_path('images/eventos/'.$id.'/'))) {
          mkdir(public_path('images/noticias/'.$id.'/'));
      }
      file_put_contents(public_path('images/noticias/'.$id.'/'.$name.'.jpg'), $data);
      return [
          //
          'image'   =&gt; $name,
          'order'   =&gt; $id + 1
      ];
  });
  </code></pre>
  
  <p>The only line that seems not to be working is </p>
  
  <pre><code>$id = factory(\App\Models\Post::class)-&gt;make()-&gt;id;
  </code></pre>
  
  <p>I did try using <code>create</code> instead of <code>make</code>, but this create more rows in the <code>post</code> table, and I don't want that.</p>
  
  <p>Is there a way to pass the <code>post</code> <code>id</code> to the images factory?</p>