Php Laravel 5.1迁移错误自动增量主

Php Laravel 5.1迁移错误自动增量主,php,mysql,laravel,migration,laravel-5.1,Php,Mysql,Laravel,Migration,Laravel 5.1,我学习Laravel有一段时间了,我为自己创建了一些基本项目,但今天我尝试迁移带有更多整数的表。但它仍然需要一个错误 每一个整数都试图自动递增并且是主要的,这可能是一个问题,但我不知道如何解决它 Schema::create ('users', function (Blueprint $table) { $table->increments ('id'); $table->string ('email')->unique(

我学习Laravel有一段时间了,我为自己创建了一些基本项目,但今天我尝试迁移带有更多整数的表。但它仍然需要一个错误

每一个整数都试图自动递增并且是主要的,这可能是一个问题,但我不知道如何解决它

        Schema::create ('users', function (Blueprint $table)
    {
        $table->increments ('id');
        $table->string ('email')->unique();
        $table->string ('pass',250);
        $table->integer ('tickets',4);
        $table->integer ('tokens',4);
        $table->integer ('in_raffle',4);
        $table->text ('profile',500);
        $table->string ('ip',20);
        $table->integer ('ban',1);
        $table->integer ('notice',1);
        $table->timestamp ('last_login');

    });

谁能告诉我,我怎样才能解决这个问题?要编辑什么才能正常工作


非常感谢,祝你有愉快的一天

删除所有
integer()中的秒数参数


问题是
integer()
方法的secont参数是
autoIncrement
,它被视为布尔值。当您传递与
false
不同的内容时,Laravel认为您希望此整数为
自动递增

函数的声明如下所示:

public function integer($column, $autoIncrement = false, $unsigned = false)
所以去掉整数长度,它就可以正常工作了。如果您想要一个小于11的整数,您可以使用
smallInteger
mediumInteger
,它们都有长度描述。

可以

$table->tinyInteger('tickets');
$table->tinyInteger('tokens');
$table->tinyInteger('in_raffle');
$table->boolean('ban')->default(false);
$table->boolean('notice')->default(false);

谢谢,它很管用!你能告诉我,我怎样才能增加整数的大小吗?因为,所有整数现在都设置为int(11),所以可以在迁移中添加大小吗?如果是,如何进行?非常感谢。不,不幸的是,在迁移中不可能做到这一点。请记住,int的大小与最小值或最大值无关,只有在使用
zerofill
时才有用。这是一篇好文章。你不能。您可以使用:
tinyInteger
smallInteger
mediumInteger
integer
biginger
$table->tinyInteger('tickets');
$table->tinyInteger('tokens');
$table->tinyInteger('in_raffle');
$table->boolean('ban')->default(false);
$table->boolean('notice')->default(false);