0
votes

there. I'm trying to deal with Laravel Framework, but there is a problem. Here is my code

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

I made migration and tried to add some fields to my table. But IDE doesn't recognize $table variable properly, so as a result I have warning: "Method increments doesn't found in class", and I can't use auto-completion.

Are there propositions how to fix this?

Whole code:

<?php

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

class CreatePostsTable extends 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
How are you running this code? Can you send us more of your code? Because your code seems perfect, at first glance. - klauskpm
It works fine, but it really hard to code, when I don't have auto-completion - TK-95

1 Answers

1
votes

Just specify the type of $table. The class is Illuminate\Database\Schema\Blueprint

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