I assume that you're trying to edit a column that you have already added data on, so dropping column and adding again as a nullable column is not possible without losing data. We'll alter the existing column.
Let say you have a migration like this:
Schema::create('users', function(Blueprint $table)
{
$table->increments('id');
$table->integer('user_id')->unsigned(); // This field should be nullable
}
However, Laravel's schema builder does not support modifying columns other than renaming the column. So you will need to run raw queries to do them, like this:
function up()
{
DB::statement('ALTER TABLE `users` MODIFY `user_id` INTEGER UNSIGNED NULL;');
}
And to make sure you can still rollback your migration, we'll do the down() as well.
function down()
{
DB::statement('ALTER TABLE `users` MODIFY `user_id` INTEGER UNSIGNED;');
}
One note is that since you are converting between nullable and not nullable, you'll need to make sure you clean up data before/after your migration. So do that in your migration script both ways:
function up()
{
DB::statement('ALTER TABLE `users` MODIFY `user_id` INTEGER UNSIGNED NULL;');
DB::statement('UPDATE `users` SET `user_id` = NULL WHERE `user_id` = 0;');
}
function down()
{
DB::statement('UPDATE `users` SET `user_id` = 0 WHERE `user_id` IS NULL;');
DB::statement('ALTER TABLE `users` MODIFY `user_id` INTEGER UNSIGNED NOT NULL;');
}