title: Laravel seeding with factory but extending it
body: <p>I want a database with two tables Users and Companies and the users table has a foreign key with the company id. So 1 company can have multiple users.  </p>
  
  <p>I created the models for this in laravel and also created a factory for each of the tables. </p>
  
  <p>In my seeders I want to create multiple data lines at once and found this solution: </p>
  
  <pre><code>factory(App\Company::class, 10)-&gt;create(); 
  </code></pre>
  
  <p>This works fine for the company table. But I need to extend this for the users table so it searches for available company Ids.<br>
  Any ideas how I can do this?<br>
  If I can't search for available Ids, I would also be happy to extend it with the "company_id" field and give it random value from 1-10 (beacause I know that these are the Ids for now). </p>
  
  <p>So basically I want to extend this to use the fields from the factory, but extend it with another field "company_id": </p>
  
  <pre><code>factory(App\Users::class, 10)-&gt;create();
  </code></pre>
  
  <p>Here is the User factory code: </p>
  
  <pre><code>$factory-&gt;define(App\User::class, function (Faker\Generator $faker) {
      return [
          'first_name' =&gt; $faker-&gt;firstName,
          'last_name' =&gt; $faker-&gt;lastName,
          'postcode' =&gt; $faker-&gt;postcode,
          'city' =&gt; $faker-&gt;city
      ];
  });
  </code></pre>