列修改器
除了上面列出的数据列类型之外,在添加列的时候还可以使用一些其它的列“修改器”,例如,要使列允许为 NULL,可以使用 nullable 方法:
Schema::table('users', function (Blueprint $table) {
  $table->string('email')->nullable();
});
下面是所有可用的列修改器列表,该列表不包含索引修改器:
| 修改器 | 描述 | 
|---|---|
| ->after('column') | 将该列置于另一个列之后 (MySQL) | 
| ->autoIncrement() | 设置 INTEGER 列为自增主键 | 
| ->charset('utf8') | 指定数据列字符集(MySQL) | 
| ->collation('utf8_unicode_ci') | 指定数据列字符序(MySQL/SQL Server) | 
| ->comment('my comment') | 添加注释信息 | 
| ->default($value) | 指定列的默认值 | 
| ->first() | 将该列置为表中第一个列 (MySQL) | 
| ->nullable($value = true) | 允许该列的值为 NULL | 
| ->storedAs($expression) | 创建一个存储生成列(MySQL) | 
| ->unsigned() | 设置 INTEGER 列为 UNSIGNED(MySQL) | 
| ->useCurrent() | 设置 TIMESTAMP 列使用 CURRENT_TIMESTAMP 作为默认值 | 
| ->virtualAs($expression) | 创建一个虚拟生成列(MySQL) | 
修改数据列
先决条件
在修改列之前,确保已经将 doctrine/dbal 依赖添加到 composer.json 文件,Doctrine DBAL 库用于判断列的当前状态并创建对列进行指定调整所需的 SQL 语句:
composer require doctrine/dbal
更新列属性
change 方法允许你修改已存在的列为新的类型,或者修改列的属性。例如,你可能想要增加 字符串类型列的尺寸,下面让我们将 name 列的尺寸从 25 增加到 50:
Schema::table('users', function (Blueprint $table) {
  $table->string('name', 50)->change();
});
我们还可以修改该列允许 NULL 值:
Schema::table('users', function (Blueprint $table) {
  $table->string('name', 50)->nullable()->change();
});
注:只有以下数据列类型能修改:bigInteger, binary, boolean, date, dateTime, dateTimeTz, decimal, integer, json, longText, mediumText, smallInteger, string, text, time, unsignedBigInteger, unsignedInteger 和 unsignedSmallInteger。
