title: Laravel Seeding using Factory for one to one relation
body: <p>I want to create a test data using laravel seed. I can seed for one table. Here is :</p>
  
  <p><strong>ModelFactory.php:</strong></p>
  
  <pre><code>/** @var \Illuminate\Database\Eloquent\Factory $factory */
  $factory-&gt;define(App\User::class, function (Faker\Generator $faker) {
      static $password;
  
      return [
          'email' =&gt; $faker-&gt;unique()-&gt;safeEmail,
          'password' =&gt; $password ?: $password = bcrypt('secret'),
          'remember_token' =&gt; str_random(10),
          'type' =&gt; '0'
      ];
  });
  </code></pre>
  
  <p><strong>UsersTableSeeder.php :</strong></p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Seeder;
  
  class UsersTableSeeder extends Seeder
  {
      /**
       * Run the database seeds.
       *
       * @return void
       */
      public function run() {
          factory(App\User::class, 50)-&gt;create()-&gt;each(function ($u) {
              $u-&gt;posts()-&gt;save(factory(App\Post::class)-&gt;make());
          });
      }
  }
  </code></pre>
  
  <p>I have two tables which are users and user_information. They have one-to-one relation. I want to seed user_information with users. But i have no idea, how i can do...</p>
  
  <p>My models relation functions :</p>
  
  <p>User.php</p>
  
  <pre><code>public function userInformation() {
          return $this-&gt;hasOne('App\UserInformation', 'user_id', 'id');
      }
  </code></pre>
  
  <p>UserInformation.php</p>
  
  <pre><code>public function users() {
          return $this-&gt;belongsTo('App\User', 'user_id', 'id');
      }
  </code></pre>
  
  <p>Laravel version is 5.3</p>
  
  <p>I followed these docs : </p>
  
  <p><a href="https://laravel.com/docs/5.3/seeding" rel="nofollow noreferrer">https://laravel.com/docs/5.3/seeding</a></p>
  
  <p><a href="https://laravel.com/docs/5.3/database-testing#writing-factories" rel="nofollow noreferrer">https://laravel.com/docs/5.3/database-testing#writing-factories</a></p>