laravel 调用未定义的方法 Illuminate\\Database\\Schema\\Blueprint::increments()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26400802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:17:11  来源:igfitidea点击:

Call to undefined method Illuminate\\Database\\Schema\\Blueprint::increments()

phpmysqllaravellaravel-4migration

提问by ?????

I'm new at laravel 4 and in my first project when I try to migrate this I got this error :

我是 laravel 4 的新手,在我的第一个项目中,当我尝试迁移这个时,我收到了这个错误:

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"}}

迁移表创建成功。{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"调用 undefiend 方法 Illuminate\Database\Schema\Blueprint::increments()","file":" foo","line:19"}}

And this my migration code in app\migration\2014_10_14_114343_add_cats_and_breeds_table.php:

这是我的迁移代码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?

任何人都可以帮我纠正错误吗?

回答by Marcin Nabia?ek

You have a typo.

你有一个错字。

Instead of:

代替:

$table->incremetns('id');

should be

应该

$table->increments('id');