'INSERT INTO table2 SELECT * FROM table1 WHERE condition in (Laravel)

I want to insert exists data which in my tables to same tables with different ids,

I have two tables products

   Schema::create('products', function (Blueprint $table) {
        $table->string('id');
        $table->UnsignedBigInteger('store_id');
        $table->char('product_id', 22);
        $table->char('variant_id', 36);
        $table->text('product_name')->nullable();
        $table->text('product_image')->nullable();
        $table->char('wish_list_id', 36);
        $table->primary('id');
        $table->foreign('wish_list_id')->references('id')->on('wish_lists')
            ->onUpdate('cascade')
            ->onDelete('cascade');
        $table->index('created_at');
        $table->timestamps();
    });

and wish_lists

 Schema::create('wish_lists', function (Blueprint $table) {
        $table->char('id', 36);
        $table->UnsignedBigInteger('store_id');
        $table->string('session_id');
        $table->string('customer_id')->nullable();
        $table->string('name');
        $table->text('description')->nullable();
        $table->enum('privacy_setting' , ['public', 'private'])->default('public');
        $table->primary('id');
        $table->index('created_at');
        $table->timestamps();
    });

There is relationship One To Many between two tables.

I want to know is there Equivalent To

INSERT INTO products
SELECT * FROM products
WHERE wishlist_id = OLD_ID;

in Laravel !?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source