我目前正在尝试使用在DatabaseSeeder :: run方法中调用的Seeder类文件,使用最新版本的Laravel(Laravel 5.1)为数据库播种。但是,当我运行db:seed
artisan方法时,我收到以下错误,并且没有新项添加到数据库中:
[ReflectionException]
Class PostsSeeder does not exist
DatabaseSeeder.php文件的来源如下:
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(PostsSeeder::class);
Model::reguard();
}
}
PostsSeeder.php文件的来源是:
use Illuminate\Database\Seeder;
class PostsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Post::class, 25)->create();
}
}