解析错误{} php迁移

时间:2016-03-07 00:19:00

标签: php laravel

我在line 50上得到一个解析错误,这是我的架构创建语句的结束括号但是我看不到任何遗漏的语法,所以我很困惑。

代码:

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {

        Schema::create('users', function (Blueprint $table) {

            $table->increments('user_id');
            $table->string('f_name');
            $table->string('l_name');
            $table->string('gender');
            $table->date('dob');
            $table->string('company_name');
            $table->string('email')->unique();
            $table->string('password');
            $table->increments('landline');
            $table->increments('mobile');
            $table->increments('activated');
            $this->increments('social_login');
            $table->timestamp('last_login');
            $table->rememberToken();
        }

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {

        Schema::drop('users');
    }
}

2 个答案:

答案 0 :(得分:4)

Schema::create(

您永远不会关闭(

    Schema::create('users', function (Blueprint $table) {

        $table->increments('user_id');
        $table->string('f_name');
        $table->string('l_name');
        $table->string('gender');
        $table->date('dob');
        $table->string('company_name');
        $table->string('email')->unique();
        $table->string('password');
        $table->increments('landline');
        $table->increments('mobile');
        $table->increments('activated');
        $this->increments('social_login');
        $table->timestamp('last_login');
        $table->rememberToken();
    });

答案 1 :(得分:0)

您正在错误地使用increments方法 - Laravel将尝试为每个$table->increments(...);语句创建一个自动递增的主键。即使指定的字段不会建议自动递增字段是合适的,您应该检查可用的方法in the Laravel docs