Laravel Drop hascolumn if exists in Migration

Today, We want to share with you Laravel Drop hascolumn if exists in Migration.In this post we will show you laravel eloquent check if record exists, hear for laravel check if model has column we will give you demo and example for implement.In this post, we will learn about how to create table through migration in laravel with an example.

Laravel Drop hascolumn if exists in Migration

There are the Following The simple About Laravel Drop hascolumn if exists in Migration Full Information With Example and source code.

Also Read This πŸ‘‰   Laravel 6 drop column if exists MySQL using Migration

As I will cover this Post with live Working example to develop Laravel Migrations – Dropping columns, so the laravel check if column exists for this example is following below.

Laravel drop column using migration.

And then here We are going to explain how to drop column step by step.

We can display we can use simple hasColumn(), as We can display below:

Schema::hasColumn(my_db_table_name, my_column_name);

And then We can display below full Laravel migration source code with example:

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
    public function up()
        Schema::table('products', function (Blueprint $table) {
    public function down()
        if (Schema::hasColumn('products', 'product_name'))
            Schema::table('products', function (Blueprint $table)

Last step To run the Database migration using command prompt.

Also Read This πŸ‘‰   Get Content and Attributes using JavaScript jQuery

php artisan migrate:rollback

Example 2: Laravel – Drop column if exists using migration

How to check column exists or not in table Laravel 5.7

if (Schema::hasColumn('subscriptions', 'stripe_id')) {
    Schema::table('subscriptions', function ($table) {

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Drop hascolumn if exists in Migration.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.