Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

devTriple's avatar

Modal has many key unique meta data, I want to query it to be in one single array

I have a Lead model with id and name,

I have a dynamicFields model with id, lead_id, key, value

their is only one unique key per lead

they are relationed as lead has many dynamic fields

example: Lead 1, john doe

dynamicFields

1,1,height, 150

2,1,width, 90

3,1,budget, 1000

I want the end query result to produce a collection/array

[
'id' => 1,
'name' => 'john doe',
'height' => 150,
'width' => 90,
'budget' => 1000,
] 
0 likes
0 replies

Please or to participate in this conversation.