Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent

Hey everyone,

I am trying to have all group a lot of models into one accessible collection such as

Forms
----> ModelForm1 - id1
----> ModelForm1 - id2
----> ModelForm2
----> ModelForm3
----> ModelForm4 - id1
----> ModelForm4 - id2

However my attempts have led to the following

Forms
----> 0
-------->ModelForm1 - id1
-------->ModelForm1 - id2
----> 1
-------->ModelForm2 - id1
etc etc,

I tried using the merge and collections but have gotten no where. How would I go about doing this

       $forms = collect();


        $buildProfile = collect(
            ['serviceHistory'=>$user->vpf->serviceHistory,
                'ribbons'=>$user->vpf->ribbons,
                'qualifications'=>$user->vpf->qualifications,
                'operations'=>$user->vpf->operations,
                'schools'=>$user->vpf->schools,
                'forms'=> [$forms->merge([$user->vpf->article15,$user->vpf->vcs,$user->vpf->ncs,$user->vpf->dcs])],
            ]);
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.