How to Change a Column Type in Laravel Migration
In this lesson, we are going to see how to change a column type in Laravel migration, let's assume that we have migrated a phone number as an integer and we want to change the column type to string.
Install the package doctrine/dbal
First, we must install the package doctrine/dbal, which is used to create the SQL queries we need to make the desired changes to the phone column.
composer require doctrine/dbal
Change the column
The change method is used to modify the type of an existing column.
Schema::table('users', function (Blueprint $table) {
$table->string('phone')->change();
});