title: Laravel - Integrity contraint violation: 1062 Duplicate entry
body: <p>I've been struggling with the problem for quite some time now and I'm getting a little bit desperate for a solution because I'm not that great at problem-solving. Anyway, I am trying to seed my database, And I followed a tutorial of Jeffrey from Laracasts in his forum series where he adds a slug to a thread. Well, I'm trying to do the same to my posts but when I seed my database I get the error stated in the title, What is causing this?</p>
  
  <p>I got my migration here:</p>
  
  <pre><code>public function up()
  {
      Schema::create('posts', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;Unsignedinteger('user_id');
          $table-&gt;Unsignedinteger('channel_id');
          $table-&gt;string('title');
          $table-&gt;longText('text');
          $table-&gt;string('slug')-&gt;unique();
          $table-&gt;timestamps();
      });
  }
  </code></pre>
  
  <p>And this is what I'm trying to do with my seeder:</p>
  
  <pre><code>public function run()
  {
      $faker = Faker\Factory::create();
      $title = $faker-&gt;sentence;
  
      foreach(range(1, 30) as $index) {
          DB::table('posts')-&gt;insert([
              'user_id' =&gt; rand(1, 50),
              'channel_id' =&gt; rand(1,14),
              'title' =&gt; $faker-&gt;sentence,
              'slug' =&gt; str_slug($title),
              'text' =&gt; $faker-&gt;paragraph,
              'created_at' =&gt; Carbon::now(),
              'updated_at' =&gt; Carbon::now(),
          ]);
  
      }
  }
  </code></pre>
  
  <p>And for the sake of keeping this question short, I'll show the full error code in a picture which is: <a href="https://imgur.com/a/ntQMX" rel="nofollow noreferrer">https://imgur.com/a/ntQMX</a></p>
  
  <p>But the problem is, In my migration, I set the slug to be unique and In my seed, I assigned the title to be equal to the slug, And that cannot be done because slug is unique, But in the tutorial, he has done the same, How can I solve this?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Link to tutorial: <a href="https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/75" rel="nofollow noreferrer">https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/75</a></p>