Recents in Beach

Laravel How to Add Multiple Column in Existing Table In Laravel

php artisan make:migration add_page_columns_to_visitor_logs_table --table=visitor_logs

php artisan make:migration add_page_columns_to_visitor_logs_table --table=visitor_logs

Migration name: 2022_06_25_130529_add_phone_field_to_users.php


public function up()

{

    Schema::table('visitor_logs', function (Blueprint $table) {

        $table->string('page_type')->nullable()->after('customer_id');

        $table->integer('page_id')->nullable()->after('page_type');

        $table->string('page_name')->nullable()->after('page_id');

    });

}

public function down()

{

    Schema::table('visitor_logs', function (Blueprint $table) {

        $table->dropColumn(['page_type', 'page_id', 'page_name']);

    });

}

php artisan migrate

Post a Comment

0 Comments