Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

athulpraj's avatar

Generate multiple user accounts

I'm building a school management application In this there is an option for teachers to create student accounts when the number of students is specified .. Which is the best possible method to do this ..

0 likes
4 replies
zachleigh's avatar
Level 47

I would just accept a student number from the teacher, make a bulkCreate method on the Student model that takes the number, then simply loop through and new up the required number if students.

1 like
jekinney's avatar

@zachleigh that would be a lot of null values?

@athulpraj Does the teacher need to provide names and other data? Teacher enters number of students then a form list is displayed for the proper amount of students. When the form is submitted create the student users. Passwords could be randomly generated and displayed to the teacher or allow the teacher to set a common password. Obviously you need to check on login so the student is required to change their password.

1 like
zachleigh's avatar

@jekinney Yeah, it would be a lot of null values, but if you want to make new students based only on a number of students, you're going to have null values no matter what you do. Maybe the OP wants to only create the empty students accounts but then let the teachers/students fill out the rest? I guess it would help to have a bit more information.

3 likes

Please or to participate in this conversation.