I have just started checking out livewire, and need some help wrapping my head around this. Lest say that i have a model Question and a model Choice. A question hasMany choices, and a choice belongsTo a question. I create a livewire view php artisan make:livewire Quiz and i pass $questions => Question::with('choices')->get() to that view. I then create another view, to display the actuall questions, one-by-one php artisan make:livewire showQuestions, but how can I go through the questions one by one by clicing a button? Should be fairly simple but i have no ide :D
@bugsysha Thanks! Currently i dont store the answers, but I will probably do that once i get the basics up and running :)
What i want to do is to grab a collection $questions => Question::with('choices')->get() and then from a livewire view, go through the collection one by one bu clicking a button (and then evaluate if the user clicked the correct alternative).
Store answered question IDs on Livewire component until you start storing it in the database and use same algorythm to exclude answered questions.
Or you can store answered question IDs on Livewire component and also store collection of questions on Livewire component and key them by ID. Then you can get the following question from that collection based on the next ID.
I would advise not to postpone adding answers. Add them right away and use them as described in my first reply. That can save a lot of time that you might spend if you overlook something.