jeudi 30 août 2018

Array not being added to variable in foreach loop

Ran into a weird problem and I'm pulling my hair out with it.

I've got this foreach loop

foreach ($rubrics as $rubric) {

            $answers = ReaderRubricAnswer::where('rubric_id', "=", $rubric->rubric_id)->get();

            $rubric['answers'] = $answers;

            Log::info($rubric['answers']);
        }

If I check the logs for $rubric['answers'] it's exactly as it should be.

However, if I var dump $rubrics, none of them have the $rubric['answers'] to them.

I know it's something simple, I've just been staring at it too long to see it now.

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2PPkEC9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire