Laravel 4-播种投掷错误
我想知道是否有人能帮我 我有一个种子文件,我已经像文档一样设置,但当我运行它时,我得到以下错误Laravel 4-播种投掷错误,laravel,laravel-4,Laravel,Laravel 4,我想知道是否有人能帮我 我有一个种子文件,我已经像文档一样设置,但当我运行它时,我得到以下错误 PHP Fatal error: Class 'Plan' not found 我的种子运行函数如下所示: DB::table('plans')->delete(); Plan::create( array( 'slug' => 'free', 'planname' => 'Free', ) ); 任何帮助都将不胜感激 干
PHP Fatal error: Class 'Plan' not found
我的种子运行函数如下所示:
DB::table('plans')->delete();
Plan::create(
array(
'slug' => 'free',
'planname' => 'Free',
)
);
任何帮助都将不胜感激
干杯,根据您的回答,请创建一个计划模型 您还需要根据您的计划创建迁移。 运行移植并创建模型后,就可以创建播种机了 您将有如下内容:
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class Plan extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'plans';
...
}
请记住模型所需的所有属性,这样数据库种子就不会有任何问题(受保护的属性等)
正如您的评论所述,出现错误的原因似乎是您使用了课程计划而没有创建课程计划 首先,您需要创建一个名为Plan的模型 转到
app/models
文件夹,然后创建一个名为:Plan.php
的文件
内部Plan.php
put:
<?php
class Plan extends Eloquent {
protected $table = 'plans';
protected $fillable = array('slug', 'planname');
}
您的Plan类是否存在于命名空间中?@seblaze-嘿,对不起,我是Laravel的新手,不太清楚这意味着什么。。。我只是按照laravel文件上的说明做了你的计划课在哪?你能附上它吗?所有这些?我没有任何计划课。。。我刚刚创建了迁移文件来创建一个Plans表,然后将上面的代码添加到PlanTableSeeder.php文件中,您需要创建一个名为Plan的模型。