Answers for "drop column if exist laravel"

PHP
3

laravel drop column if exists

if (Schema::hasColumn('users', 'phone')) {
 	Schema::table('users', function (Blueprint $table){
       $table->dropColumn('phone');
    });
}
Posted by: Guest on November-13-2020
2

laravel drop column if exists

Schema::table('users', function (Blueprint $table) {
     $table->dropColumn('name');
});
Posted by: Guest on September-17-2020
1

drop column table in migration if exist in laravel

Schema::table('users', function (Blueprint $table) {
     if (Schema::hasColumn('users', 'phone')) {
              $table->dropColumn('phone');
		}
});
Posted by: Guest on August-04-2021

Browse Popular Code Answers by Language