I have a quiz app which has the standard questions and answers etc. I can do this by calling a seeder class: What if I want to create a quiz with a variable number of questions, answers and user responses?
What if I create an artisa n command to take in my arguments and pass them to my seeder?
In my case, I want to set default values if I don’t pass anything, so I did this for my number of questions and answers: This means I can call the following commands: As you can see the parameters -Q and — questions are equivalent and optional. Now in the handle function, we need to get the options for questions & answers, and run the seeder: Now I can access these class-level variables in the seeder, and write my seeder using those parameters.