调用未定义的方法Illuminate \\ Database \\ Schema \\ Blueprint :: increments() [英] Call to undefined method Illuminate\\Database\\Schema\\Blueprint::increments()
问题描述
我是laravel 4的新手,在我的第一个项目中,尝试迁移此错误时,我遇到了这个错误:
I'm new at laravel 4 and in my first project when I try to migrate this I got this error :
迁移表已成功创建. {错误":{类型":"Symfony \ Component \ Debug \ Exception \ FatalErrorException",消息":调用 捍卫方法 Illuminate \ Database \ Schema \ Blueprint :: increments()," file:" foo," line:19}}
Migration table created successfully. {"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to undefiend method Illuminate\Database\Schema\Blueprint::increments()","file":"foo","line:19"}}
这是我在app\migration\2014_10_14_114343_add_cats_and_breeds_table.php
中的迁移代码:
And this my migration code in 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');
}
}
任何人都可以帮助我纠正错误吗?
Can any one help me correct the error?
推荐答案
您有错字.
代替:
$table->incremetns('id');
应该是
$table->increments('id');
这篇关于调用未定义的方法Illuminate \\ Database \\ Schema \\ Blueprint :: increments()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!