laravel drop column if exists migration code example
Example 1: laravel drop column if exists
if (Schema::hasColumn('users', 'phone')) {
Schema::table('users', function (Blueprint $table){
$table->dropColumn('phone');
});
}
Example 2: laravel migration remove column
public function up()
{
Schema::table('table', function($table) {
$table->dropColumn('column_name');
});
}
Example 3: laravel drop column if exists
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('name');
});