-
我用
php artisan make:model Comment
命令创建了一个新模型 -
我使用以下代码创建了一个名为
CommentTableSeeder
的新数据库播种机:
<?php
使用Illuminate \ Database \ Seeder;
class CommentTableSeeder扩展了Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('comments')->delete();
Comment::create(array(
'author' => 'A name',
'text' => 'Hello all nice website'
));
Comment::create(array(
'author' => 'name2',
'text' => 'Hahahahha'
));
Comment::create(array(
'author' => 'Name 3,
'text' => 'I destroy your car'
));
}
}
- 我运行了
php artisan db:seed
命令,我收到错误:Class 'Comment' not found
为什么?
1 回答
添加以下行:
此外,您可以使用此:
代替