【发布时间】:2016-07-06 04:24:09
【问题描述】:
- 我使用
php artisan make:model Comment命令创建了一个新模型 -
我使用以下代码创建了一个名为
CommentTableSeeder的新数据库播种器:<?php
使用 Illuminate\Database\Seeder;
类 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
为什么?
【问题讨论】:
-
您之前是否运行过迁移?
-
如果你的意思是数据库迁移,是的
-
请分享您的完整播种代码?