Laravel - 运行迁移时出现异常

时间:2014-03-17 17:05:39

标签: laravel laravel-4

我正在尝试运行迁移,但出现以下错误:

  

{"错误" {"类型":" Symfony的\元器件\调试\异常\ FatalErrorException""消息":& #34;调用   到一个成员函数incrementments()   非对象""文件":" /Applications/MAMP/htdocs/khadamat/app/database/migrations/2014_03_17_165445_create-users-table.php","线" 16}} {"错误" {"类型":" Symfony的\元器件\调试\异常\ FatalErrorException""消息& #34;:"呼叫   到一个成员函数incrementments()   非对象""文件":" /Applications/MAMP/htdocs/khadamat/app/database/migrations/2014_03_17_165445_create-users-table.php","线" 16}}

这是包含第16行的代码:

class CreateUsersTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        $table->increments('id');
        $table->string('firstname', 40);
        $table->string('lastname', 40);
        $table->string('dob', 40);
        $table->string('email', 150)->unique();
        $table->string('password', 64);
        $table->string('address', 200);
        $table->string('city', 40);
        $table->string('country', 100);
        $table->string('register_purpose', 40);
        $table->timestamps();

    }

为什么会发生这种情况有任何明确的理由?提前致谢

1 个答案:

答案 0 :(得分:2)

更好地使用工匠工具生成迁移... creating-migrations ..我的项目迁移表中的一些代码......

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateVideosTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('videos', function(Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->text('description');
        $table->string('image');
        $table->text('embed');
        $table->timestamps();
    });
}


/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('videos');
}

}
相关问题