Answers for "check if foreign key exists before dropping column in laravel 8"

PHP
2

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
3

laravel remove foreign key

$table->dropForeign('posts_user_id_foreign');
Posted by: Guest on April-22-2020

Code answers related to "check if foreign key exists before dropping column in laravel 8"

Browse Popular Code Answers by Language