title: Laravel seeding - unique pairs of user and teacher IDs
body: <p>I am using database migration and seeding in Laravel 5.1.</p>
  
  <p><strong>Migration</strong></p>
  
  <pre><code>public function up()
  {
      Schema::create('teachers', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;integer('user_id')-&gt;unsigned();
          $table-&gt;integer('teacher_id')-&gt;unsigned();
          $table-&gt;boolean('disable')-&gt;default(0);
          $table-&gt;timestamps();
  
          $table-&gt;unique(['user_id', 'teacher_id']);
  
          $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade');
          $table-&gt;foreign('teacher_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade');
      });
  }
  </code></pre>
  
  <p>*** user_id and teacher_id must be unique together.</p>
  
  <p><strong>Model Factory</strong></p>
  
  <pre><code>$factory-&gt;define(App\Teacher::class, function ($faker) {
      return [
          'user_id'           =&gt; $faker-&gt;numberBetween(1, 59),
          'teacher_id'        =&gt; $faker-&gt;numberBetween(1, 59),
      ];
  });
  </code></pre>
  
  <p>I set up the seeder for producing 500 teacher relational in <code>DatabaseSeeder.php</code>:
  <code>factory(App\Teacher::class, 500)-&gt;create();</code></p>
  
  <p>but i got this error:</p>
  
  <pre><code>[PDOException] 
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '10-11' for key 'teachers_user_id_teacher_id_ 
  unique'
  </code></pre>
  
  <p>As you can see, the *** (unique property) caused the error.
  is there any way to fix it? What is your idea?</p>