Allow Adding Multiple Columns After A Column In Laravel

In this quick example i will show you how we can add multiple column after a column in Laravel. So Allow adding multiple columns after a column in Laravel you have to follow this below code. Just do it. You can check the merge request from this link Allow adding multiple columns after a column

Schema::table('users', function (Blueprint $table) {
    $table->after('remember_token', function ($table){
        $table->string('card_brand')->nullable();
        $table->string('card_last_four', 4)->nullable();
    });
});

 

The order of the columns will be:

  • remember_token
  • card_brand
  • card_last_four

Hope it can help you.

 

#laravel #laravel-8x #migrations