当我尝试迁移我的配置文件表时,它给了我错误。我正在使用 laravel 5.1

Uza*_*han -3 laravel laravel-5 laravel-validation

[Symfony\Component\Debug\Exception\FatalErrorException] 语法错误,意外的 '(',需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或 '{' 或 '$'

这是我的代码

public function up()
        {
            Schema::create('profile', function (Blueprint $table) {
                $table->('userid')->unsigned()->default(0);
                $table->string('profile')->default('http://localhost/laravel/public/image/uzair.jpg');
                $table->string('about',255);
                $table->foreign('userid')->references('id')->on('users')->onDelete('cascade');
                $table->timestamps();
            });
        }
Run Code Online (Sandbox Code Playgroud)

Hka*_*kan 5

$table->('userid')
Run Code Online (Sandbox Code Playgroud)

这就是您收到语法错误的原因。应该是$table->integer('userid')