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

标签 php mysql laravel laravel-4 migration

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

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

关于php - 调用未定义的方法 Illuminate\\Database\\Schema\\Blueprint::increments(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26400802/

相关文章:

java - log4j2 的 SQL 异常

php - 使用 Codeigniter 从 MySQL 查询创建多维数组

php - 警告 : mysqli_select_db() expects parameter 1 to be mysqli, 给出 null

php - MySQL:是否可以缩短错误消息?

mysql - 如何获取最新的 mySQLdump 工具

PHP PDO,连接有效,购买查询未执行

php - 修复尝试从数据库检索数据时 php 中的显示格式

php - 如何在 Laravel 5.4 中编辑 php 设置以接受大型 csv 文件上传?

php - 找不到 Laravel 4 迁移基表

带有 groupby、count 和 sum 的 Laravel 集合