Import users from another project

Solved
stefcristian3

Sep 22nd, 2022 04:50 AM

Hello, someone import with success users from another laravel project?

thinkverse

Sep 22nd, 2022 05:08 AM

Fully depends on the project. Laravel doesn't come with that functionality out of the box. Does your Laravel application have a way of importing and parsing imported users? And does the other application have a way of exporting users?

And if so what is exported? The usernames, emails, names, passwords, created at dates, any other fields associated with the user? What about relational tables?

Passwords are hopefully hashed so they cannot be exported and imported, so for imported users you'll have to send out and email asking them to enter a new password.

Also, have the users given you permission to export their accounts and import them into another application? User information is considered PII in most countries and there are privacy laws that need to be followed.

Report
1
bobbyiliev

Sep 22nd, 2022 05:17 AM

Best Answer

Hi there,

I think that this should be doable but with a little bit of custom code to parse your file containing the users.

What you could do is:

  • Export your old users in a CSV or JSON file for exmaple
  • Create an artisan command that takes that file as an argument and loops through all users defined in the file and creates the users in your current project

Here is a good video example that shows how you could create a bulk users import functionality:

Importing CSV data in Laravel to bulk import users

In the video, they use a HTTP controller, but this should work in a similar way with an artisan command too.

The users, might have to reset their passwords, unless you are using the same app key for both projects.

Let me know how it goes!

Best,

Bobby

stefcristian3

Sep 22nd, 2022 05:20 AM

It is dog sport platform that i will be migrate to Wave(i have update from Laravel 5.7 to last laravel version), Yes the users have been asked if they are agree to move them on the new platform(and they are agree ...we are a small association like comunity). Yes the passwords are hashed. And i also go to the idea to send an e-mail to change their password is the best and legal way, when i will finish the new app. You clarify me, i believe the question was answered.

stefcristian3

Sep 22nd, 2022 05:27 AM

Thnx Bobby, this seams even better ...i will go on this solution, i will let you know about progress, i do not believe that is so big issue to change their passwords.

Report
1
bobbyiliev

Sep 22nd, 2022 05:50 AM

Sounds like a plan! Hope that it all goes smoothly!

stefcristian3

Sep 27th, 2022 11:03 PM

I have imported the users from old project with passwords via seeder method. Seams that encryption method remain the same from laravel 5.7 thil 9.xx.

bobbyiliev

Sep 28th, 2022 12:41 AM

That is great, happy to hear that you've got it all working!