title: Laravel seed table from multiple csv files
body: <p>I'm very new to Laravel and Database and I'm trying to understand how to insert data into my database. Please be patient the question can sounds dummy for you.</p>
  <ol>
  <li>STEP</li>
  </ol>
  <p>I created a table in migrations. Example of a table:</p>
  <pre><code>public function up(){
  
          Schema::create('job-urls', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;foreign('job_id')-&gt;references('id')-&gt;on('jobs');
              $table-&gt;string('url')-&gt;index();
              $table-&gt;string('hash');
              $table-&gt;timestamp('created_at')-&gt;nullable();
              $table-&gt;timestamp('updated_at')-&gt;nullable();
      
  </code></pre>
  <ol start="2">
  <li>STEP</li>
  </ol>
  <p>I have two csv file that correspond to the field <code>url</code> and <code>hash</code> and I want to insert them. I created a new file in migration called <code>populate_jobs_url</code></p>
  <pre><code>class PopulateJoburls extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up(){
          $fileurls = fopen('../data/urls.csv', 'r');
          $filehash = fopen('../data/urls_hash.csv', 'r');
  
          while (($row = fgetcsv($fileurls, 0, ',')) !=FALSE){
              DB::table('joburls')-&gt;insert(
                  array(
                      'url' =&gt; $row,
                  )
              );
          }
          while (($row = fgetcsv($filehash, 0, ',')) !=FALSE){
              DB::table('joburls')-&gt;insert(
                  array(
                      'hash' =&gt; $row,
                  )
              );
          }
      }
  </code></pre>
  <p>Can you help me to understand how I check if the table is correctly filled? Is this approach correct? How could I insert data otherwise in my Database? Unfortunately all examples on the web deal with inserting manually data with a form.</p>
  <p>Thanks</p>