2014-04-20 110 views
0

我使用php artisan migrate:make在Laravel中创建了表迁移。当我尝试在数据库中创建表格时,出现错误:ErrorException:从空值创建默认对象

[ErrorException] 
Creating default object from empty value 

这与此相关的是什么?没有创建表格,也不能在我的迁移中找到任何错误。

我有25个表中的migrations文件夹,所有的外观都与此类似。

<?php 

use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class CreateAddressesTable extends Migration { 
    public function up() { 
     Schema::create("addresses", function() { 
      $table->engine = "InnoDB"; 

      $table->increments("id"); 
      $table->integer("user_id")->unsigned(); 

      $table->string("street"); 
      $table->string("city"); 
      $table->integer("postal_code")->unsigned(); 

      $table->foreign("user_id")->references("id")->on("users"); 

      $table->softDeletes(); 
      $table->timestamps(); 
     }); 
    } 

    public function down() { 
     Schema::dropIfExists("addresses"); 
    } 
} 

回答

2

那么你错过了$表,你传递给函数。

你的架构创建功能需要在这种风格......

模式::创建我刚好复制和粘贴(“地址”,函数(蓝图$表)

+0

尼斯渔获物。在这里只有错误的文件,这是25个文件中唯一缺失的文件,谢谢。 – MikkoP

相关问题