Mass insert and update of over 5 thousand array data

Posted 1 week ago by softwebglobe

I have more than 5 thousand array data to updateOrCreate in my laravel model.

the challenge is if it's possible to run this update or create command without using foreach or any loop?

The Json array I want to mass update or create is like bellow:

VASHTI: {country: "India", sex: "F", amount: "600", status: 0}
HENRY: {country: "USA", sex: "M", amount: "600", status: 1}
MARRY: {country: "India", sex: "F", amount: "600", status: 0}

Now the array outermost key is the name of the user and I have thousands of this records, my question is how do I mass save and mass update this records in laravel. Using the latest laravel version 5.8.

my user model have the column names:

*username* *country* *sex* *amount* *status*

This records change in bulk so it also requires bulk updateOrCreate

Please sign in or create an account to participate in this conversation.