title: Laravel 5.1 foreign keys in model factory
body: <p>How do you define foreign keys in a model factory. For example if I have a organisations table which has a foreign key to the countries table, in my model factory I'm having to define a dummy value for the country id as follows:</p>
  
  <pre><code>$factory-&gt;define(App\Organisation::class, function ($faker) {
     return [
        'name' =&gt; $faker-&gt;company,
        'country_id' =&gt; 197,
     ];
  });
  </code></pre>
  
  <p>In my organisations table seeder class I am doing the following but the faker object isn't present - do I need to create a new faker object in my seeder class? </p>
  
  <pre><code>use Illuminate\Database\Seeder;
  
  class OrganisationsTableSeeder extends Seeder
  {
  
     public function run()
     {
        $countryIds = Country::lists('id')-&gt;all();
  
        factory('App\Organisation', 3)-&gt;create([
          // override factory default
          'country_id' =&gt; $faker-&gt;randomElement[$countryIds],
      ]);
     }
  }
  </code></pre>
  
  <p>Database seeder class</p>
  
  <pre><code>class DatabaseSeeder extends Seeder
  {
       public function run()
       {
  
          Model::unguard();
  
          $this-&gt;call('CountriesTableSeeder');
          $this-&gt;call('OrganisationsTableSeeder');
  
          Model::reguard();
       }
  }
  </code></pre>
  
  <p>Whats the best way to define the foreign keys when defining model factories? Is it possible to omit the country_id from the model factory and add it in the seeder class instead - from the documention it seems you can only override an existing value defined in the model factory but you cant add a new value via the seeder class - correct me if i'm wrong?</p>