title: Creating a seeder in Laravel 6 that works with foreign key constraint
body: <p>I am trying to create a seeder that fills a databases with "Assignments" that are linked with a "Course" database with foreign key constraint.
  Since i am pretty new to PHP and Laravel 6 in general i don't really know where to start.
  I allready have a seeder that fills my "Course" database, which like this:</p>
  
  <pre><code>class  CoursesTableSeed extends Seeder
  {
      /**
       * Run the database seeds.
       *
       * @return void
       */
      public function run()
      {
          DB::table('courses')-&gt;insert([[
              'name' =&gt; 'Opleidings- en beroepsoriëntatie',
              'ecs' =&gt; '2.5'
          ],[
              'name' =&gt; 'Computer science basics',
              'ecs' =&gt; '7.5'
          ],[
              'name' =&gt; 'Programming basics',
              'ecs' =&gt; '5'
          ],[
              'name'=&gt;'Professional skills 1',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'HZ Personality',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'Object-oriented programming',
              'ecs'=&gt;'10',
  
          ],[
              'name'=&gt;'Professional skills 2',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'Professionele werkplek',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'Framework development 1',
              'ecs'=&gt;'5',
  
          ],[
              'name'=&gt;'Framework project 1',
              'ecs'=&gt;'5',
  
          ],[
              'name'=&gt;'Professional skills 3',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'IT Personality 1',
              'ecs'=&gt;'2.5',
  
          ],[
              'name'=&gt;'Framework development 2',
              'ecs'=&gt;'5',
  
          ],[
              'name'=&gt;'Framework project 2',
              'ecs'=&gt;'5',
  
          ]
          ]);
      }
  }
  </code></pre>
  
  <p>Now i want to do the same thing with my assignment database but i cant figure out how since i also want to have the "Assignments" linked with theyr respective "Course" so when i delete a course it also deletes it associated assignments. If this question comes over a little vague, sorry for that. I am pretty new to PHP laravel and programming in general.
  Also, this is my migration for the assignments:</p>
  
  <pre><code>class CreateAssignmentsTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('assignments', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;unsignedBigInteger('course_id');
              $table-&gt;text('name');
              $table-&gt;decimal('weight',3,1)-&gt;nullable();
              $table-&gt;decimal('grade', 3, 1)-&gt;nullable();
              $table-&gt;timestamps();
  
              $table-&gt;foreign('course_id')
                  -&gt;references('id')
                  -&gt;on('courses')
                  -&gt;onDelete('cascade');
  
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('assignments');
      }
  }
  </code></pre>