Php laravel,使用Eloquent时从空值创建默认对象

Php laravel,使用Eloquent时从空值创建默认对象,php,laravel-4,codeception,Php,Laravel 4,Codeception,我正在使用laravel和codeception 我想将表单的内容存储到一个名为websites的表中,我创建了一个model Website.php(默认模板如文档所示)和一个resource WebsiteController.php 根据codeception,路由正在按预期工作 我在WebsiteController.php的store方法中有以下代码: $website_name = Input::get('website_name'); $website = new Website

我正在使用laravel和codeception

我想将表单的内容存储到一个名为websites的表中,我创建了一个model Website.php(默认模板如文档所示)和一个resource WebsiteController.php

根据codeception,路由正在按预期工作

我在WebsiteController.php的store方法中有以下代码:

$website_name = Input::get('website_name');

$website = new Website;
$website->name = $website_name;       // line with the probleme
$website->save();

return 'success';
当我填写表单并发送表单时,我得到一个错误:从空值创建默认对象,指向上面的注释行

<?php

class Website extends Eloquent {
   // empty class
}

这听起来很明显,也许您已经尝试过了,但是您是否可以将$website\u name的值硬编码为,然后查看是否会遇到相同的问题?我怀疑你实际上并没有检索“网站名称”。你能发布
var\u dump($website)的输出吗就在实例化它之后?发布Website.php内容也会很有帮助。@Hassan这实际上是一个我没有想到的聪明主意,但它不起作用。您的迁移是什么?
object(Website)#158 (20) { ["fillable":protected]=> array(4) { [0]=> string(4) "link" [1]=> string(4) "type" [2]=> string(4) "name" [3]=> string(11) "description" } ["connection":protected]=> NULL ["table":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(0) { } ["original":protected]=> array(0) { } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["morphClass":protected]=> NULL ["exists"]=> bool(false) }