3

I entered php artisan db:seed but it skip seeding CountriesRetailerSeeder.

It seeds when I do it manually.

php artisan db:seed --class=CountriesRetailerSeeder

How will I be able to run it in php artisan db:seed along with the other seeders ?

here's the code in my CountriesRetailerSeeder

use Illuminate\Database\Seeder;
use League\Csv\Reader;
use App\CountryRetailer;

public function run()
{
     DB::table('country_retailer')->truncate();
     $file = base_path().'/database/seeds/country_retailer_csv.csv';
     $reader = Reader::createFromPath($file);

     $data = array();
     $count_elements = 0;
     foreach($reader as $index => $row)
     {
         $data[$count_elements] = array('country'=>$row[0],'original_header'=>$row[1],'count'=>$row[2],
         'channel'=>$row[3],'retailer'=>$row[4],
         'website'=>$row[6],'contacts'=>$row[7],'notes'=>$row[8]);

         $count_elements++;
     }
     $cr = new CountryRetailer;
     $cr::insert($data);
}

Take not that all of those 2000 rows of data is from a csv file.

KennethC
  • 746
  • 2
  • 10
  • 27
  • 2
    Have you added it to database/seeds/DatabaseSeeder.php? https://laravel.com/docs/5.1/seeding#calling-additional-seeders – markdwhite Mar 01 '16 at 07:01
  • 1
    Yes, I updated my code. I don't get an error or anything, my problem is it doesnt seed when i use php artisan db:seed. but it works fine when I use php artisan db:seed --class=CountriesRetailerSeeder – KennethC Mar 01 '16 at 07:05

0 Answers0