我是laravel 4的新手,在我的第一个项目中,当我尝试迁移它时,我得到了这个错误:
迁移表创建成功。{"error":{"type":"Symfony''Component''Debug''Exception''FatalErrorException","message":"调用到未定义方法Illuminate''Database''Schema''Blueprint::increments()","file":"foo","line:19"}}
这是我在app'migration'2014_10_14_114343_add_cats_and_breeds_table.php
:中的迁移代码
use Illuminate'Database'Schema'Blueprint;
use Illuminate'Database'Migrations'Migration;
class AddCatsAndBreedsTable extends Migration {
public function up()
{
Schema::create('cats', function($table){
$table->increments('id');
$table->string('name');
$table->date('date_of_birth')->nullable();
$table->integer('breed_id')->nullable();
$table->timestamps();
});
Schema::create('breeds', function($table){
$table->incremetns('id');
$table->string('name');
});
}
public function down()
{
Schema::drop('cats');
Schema::drop('breeds');
}
}
有人能帮我纠正这个错误吗?
您有一个打字错误。
代替:
$table->incremetns('id');
应该是
$table->increments('id');