【问题标题】:Call to undefined method Illuminate\\Database\\Schema\\Blueprint::increments()调用未定义的方法 Illuminate\\Database\\Schema\\Blueprint::increments()
【发布时间】:2014-12-11 14:34:58
【问题描述】:

我是 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');
}

}

谁能帮我纠正错误?

【问题讨论】:

    标签: php mysql laravel laravel-4 migration


    【解决方案1】:

    你有一个错字。

    代替:

    $table->incremetns('id');
    

    应该是

    $table->increments('id');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-25
      • 2022-12-21
      • 2021-12-30
      • 2021-04-12
      • 1970-01-01
      • 2019-09-28
      • 2014-04-23
      相关资源
      最近更新 更多