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

限于喜欢 提交于 2019-12-10 14:50:03

问题


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

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

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?


回答1:


You have a typo.

Instead of:

$table->incremetns('id');

should be

$table->increments('id');


来源:https://stackoverflow.com/questions/26400802/call-to-undefined-method-illuminate-database-schema-blueprintincrements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!