Laravel migration table field's type change

To change the type of a field in a table using a migration in Laravel, you can use the change method on the Schema facade. For example, to change the type of a field named "email" in a table named "users" from a string to an integer, you can use the following code in your migration file:

Schema::table('users', function (Blueprint $table) {
    $table->integer('email')->change();
});

Watch a course Learn object oriented PHP

You can also change the field name, default value and other attributes in the same change method.

Schema::table('users', function (Blueprint $table) {
    $table->string('email', 100)->nullable()->change();
});

Then run the migration using the command php artisan migrate.