6 Replies
my current code:
Why would you want to do that? What are you trying to accomplish? This isn’t a Filament question but I’ll try to help you if I can better understand what you are trying to do
Thanks for your help sir, so basically what I'm doing is a quiz, and this is a part before I send all data to a form repeater and display all questions. So what is happening in the foreach is that it takes the formulario_id (translated is quiz_id) from the pivot table (called cargo_formulario) and I'm trying to search for all the 'pergunta' (question) and trying to display its 'texto' (text)
that ->toArray() is a mistake😅
the foreach is taking the right 'id' in that first dd(), but the secound one returns nothing, #items: []
You should use a
whereIn
insteadOn your Cargo model, have you considered creating a many to many relationship named ‘questions’ that is the same as the relationship to Formulario but includes the where clause to only get the questions?
Thank you, it worked
$formulario = Formulario::query('ativo', true)->whereIn('id', $formularioId);
thanks for the tip, I have already done it on the tabs in my question resource