我进入php artisan db:seed
但它跳过播种 CountryRetailerSeeder。
当我手动进行时,它会播种。
php artisan db:seed --class=CountriesRetailerSeeder
我将如何php artisan db:seed
与其他播种机一起运行它?
这是我的CountryRetailerSeeder中的代码
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);
}
不要认为所有这 2000 行数据都来自csv 文件。