首页 文章

在类中找不到方法增量 . Laravel

提问于
浏览
0

那里 . 我正在尝试处理Laravel Framework,但是有一个问题 . 这是我的代码

public function up()
    {
        Schema::create('users', function($table)
        {
            $table->increments('id');
        });
    }

我进行了迁移,并试图在我的表中添加一些字段 . 但IDE无法正确识别$ table变量,因此我发出警告:“在类中找不到方法增量”,我无法使用自动完成 .

有没有提出如何解决这个问题?

整码:

<?php

使用Illuminate \ Database \ Schema \ Blueprint;使用Illuminate \ Database \ Migrations \ Migration;

class CreatePostsTable扩展了Migration {

public function up()
{
    Schema::create('posts', function($table)
    {
        $table->increments('id');
        $table->string('title',150);
        $table->text('body');
        $table->string('preview',300);
        $table->string('author',100);
        $table->timestamps();
    });
}


public function down()
{
    Schema::drop('posts');
}

}

1 回答

  • 1

    只需指定 $table 的类型即可 . 这堂课是 Illuminate\Database\Schema\Blueprint

    Schema::create('users', function(Blueprint $table)
    {
        $table->increments('id');
    });
    

相关问题