我的播种机类代码如下:
<?php
use AppCategory;
use IlluminateDatabaseSeeder;
class CategoryTableSeeder extends Seeder
{
public function run()
{
DB::table('categories')->delete();
$cats = ['math', 'physics', 'calculus', 'eletronics', 'etc etc'];
foreach ($cats as $cat)
{
Category::create(['category' => $cat]);
}
}
}
当我尝试使用CLI上的以下命令进行播种时:
PHP手工DB:种子
什么也没有发生任何错误。这可能怎么了?我在Github上看到了类似的讨论,但没有找到解决方案。您的帮助将不胜感激。
尝试php artisan db:seed --class=CategoryTableSeeder
如果您想始终运行此种子添加$this->call('CategoryTableSeeder');
在数据库Ederer中